".
This class can be used to print out system information at the
command line by issuing the command:
java org.apache.derby.tools.sysinfo
Alternatively, you can use SysInfo within your program to display
Derby information; a Derby version string is returned by this Java code:
new Main().toString();
Field Summary |
private static java.lang.String |
CLIENT
|
private static boolean |
cptester
|
private static java.lang.String |
curLoc
|
private static java.lang.String |
DB2DRIVER
|
private static java.lang.String |
EMBEDDED
|
private static java.lang.String |
failureTag
The name of the failure tag in the information file. |
private static java.lang.String[] |
infoNames
|
private static java.lang.String |
javaSep
|
private static java.lang.String |
jbmsSep
|
private static java.lang.String |
licSep
|
private static LocalizedResource |
LOCALIZED_RESOURCE
Resource for localizing the sysinfo messages. |
private static java.lang.String |
locSep
|
private static java.lang.String |
MAINUSAGESTRING
|
private static java.lang.String |
MESSAGE_FILE
Name of file which contains messages for sysinfo. |
private static java.lang.String |
NET
|
private static java.lang.String |
sep
for use by the main () method |
private static boolean |
setLicense
|
private static boolean |
setPause
|
private static java.lang.String |
TOOLS
|
private static java.lang.String |
USAGESTRINGPARTA
|
private static java.lang.String |
USAGESTRINGPARTB
|
Constructor Summary |
Main()
|
Method Summary |
private static java.lang.String |
argumentMatches(java.lang.String[] args,
java.lang.String ss)
|
private static boolean |
argumentsContain(java.lang.String[] args,
java.lang.String s)
|
private static ZipInfoProperties |
checkDirectory(java.lang.String dirname)
Check a given directory for the presence of an info properties file in
org/apache/derby/info inside the directory. |
private static ZipInfoProperties |
checkFile(java.lang.String filename)
Check inside a jar file for the presence of a Derby info properties
file. |
private static ZipInfoProperties |
checkForInfo(java.lang.String cpEntry)
Given an individual element of the element of the classpath, call
checkDirectory() if the element is a directory or checkFile()
if the element is a file. |
private static java.lang.String |
crLf()
|
private static java.lang.String |
formatURL(java.net.URL loc)
Strip a given URL down to the filename. |
private static java.lang.String |
found(java.lang.String cn,
java.lang.String library,
java.lang.String loc)
|
static ZipInfoProperties[] |
getAllInfo(java.lang.String classpath)
Get all the info we can obtain from the local execution context
as to the availability of the Derby classes by attempting to load
the info files with loadZipFromResource() and checking classpath
locations with checkForInfo if the classpath is accessible. |
private static void |
getClasspathInfo(java.lang.String[] args,
java.io.PrintWriter aw)
|
static java.lang.String |
getCompleteMessage(java.lang.String msgId,
java.lang.Object[] arguments)
|
private static java.lang.String |
getFileWhichLoadedClass(java.lang.Class cls)
Given a loaded class, this
routine asks the class's class loader for information about where the
class was loaded from. |
private static java.lang.String |
getJavaProperty(java.lang.String whichProperty)
Return Java properties from java.lang.System. |
private static java.lang.String |
getJavaProperty(java.lang.String whichProperty,
boolean nullUnavailable)
Return Java properties from java.lang.System. |
static void |
getMainInfo(java.io.PrintWriter aw,
boolean pause)
|
static java.lang.String |
getTextMessage(java.lang.String msgId)
|
static java.lang.String |
getTextMessage(java.lang.String msgId,
java.lang.Object a1)
|
static java.lang.String |
getTextMessage(java.lang.String msgId,
java.lang.Object a1,
java.lang.Object a2)
|
static java.lang.String |
getTextMessage(java.lang.String msgId,
java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3)
|
static java.lang.String |
getTextMessage(java.lang.String msgId,
java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3,
java.lang.Object a4)
|
private static ZipInfoProperties[] |
loadZipFromResource()
Attempt to load the info properties files specified in infoNames[i]
using getResourceAsStream(). |
private static java.lang.String |
lookForMainArg(java.lang.String[] args,
java.io.PrintWriter localPW)
|
static void |
main(java.lang.String[] args)
Application entry point for SysInfo. |
private static ZipInfoProperties[] |
mergeZips(ZipInfoProperties[] zip1,
ZipInfoProperties[] zip2)
Merge and flatten two arrays of ZipInfoProperties, removing any
duplicates. |
private static java.lang.String |
notFound(java.lang.String cn,
java.lang.String library)
|
private static void |
parseArgs(java.lang.String[] args)
|
private static java.lang.String[] |
parseClasspath(java.lang.String cp)
Split the classpath into separate elements. |
private static void |
pause()
For the benefit of DOS box users, this method waits for input
before returning |
private static void |
printPropertyIfNotNull(java.io.PrintWriter localAW,
java.lang.String property)
Print property only if not null |
private static void |
reportDerby(java.io.PrintWriter localAW)
prints out the jbms info to the specified AppStreamWriter. |
private static void |
reportJavaInfo(java.io.PrintWriter localAW)
Writes out the relevant info about the Java environment to
the specified AppStreamWriter. |
private static void |
reportLocales(java.io.PrintWriter localAW)
Writes out information about the locales with the
product. |
private static void |
tryAllClasspaths(java.io.PrintWriter localPW)
|
private static void |
tryAsResource(java.lang.String cn,
java.lang.String library,
java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
|
private static void |
tryClientClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
|
private static void |
tryCoreClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
|
private static void |
tryDB2DriverClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
|
private static void |
tryMyClasspath(java.lang.String cn,
java.lang.String library,
java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
|
private static void |
tryNetClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
|
private static void |
trySomeClasspaths(java.lang.String[] args,
java.io.PrintWriter localPW)
|
private static void |
tryUtilsClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
|
(package private) static void |
useMe(java.lang.String[] args,
java.io.PrintWriter pw)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MESSAGE_FILE
private static final java.lang.String MESSAGE_FILE
- Name of file which contains messages for sysinfo.
- See Also:
- Constant Field Values
LOCALIZED_RESOURCE
private static final LocalizedResource LOCALIZED_RESOURCE
- Resource for localizing the sysinfo messages.
The default LocalizedResource reads messages from the toolsmessages
bundle. Create this instance to read messages from sysinfoMessages. Use
the locale and codeset specified by derby.ui.locale and derby.ui.codeset
if they are set.
Note that this variable must be initialized when the class is loaded in
order to work correctly for the API methods that don't call
main()
.
setPause
private static boolean setPause
setLicense
private static boolean setLicense
cptester
private static boolean cptester
sep
private static final java.lang.String sep
- for use by the main () method
- See Also:
- Constant Field Values
javaSep
private static final java.lang.String javaSep
jbmsSep
private static final java.lang.String jbmsSep
licSep
private static final java.lang.String licSep
locSep
private static final java.lang.String locSep
curLoc
private static final java.lang.String curLoc
failureTag
private static final java.lang.String failureTag
- The name of the failure tag in the information file.
The failure tag's value provides a default value if
any other properties are missing.
EMBEDDED
private static final java.lang.String EMBEDDED
- See Also:
- Constant Field Values
TOOLS
private static final java.lang.String TOOLS
- See Also:
- Constant Field Values
NET
private static final java.lang.String NET
- See Also:
- Constant Field Values
CLIENT
private static final java.lang.String CLIENT
- See Also:
- Constant Field Values
DB2DRIVER
private static final java.lang.String DB2DRIVER
- See Also:
- Constant Field Values
MAINUSAGESTRING
private static final java.lang.String MAINUSAGESTRING
- See Also:
- Constant Field Values
USAGESTRINGPARTA
private static final java.lang.String USAGESTRINGPARTA
- See Also:
- Constant Field Values
USAGESTRINGPARTB
private static final java.lang.String USAGESTRINGPARTB
- See Also:
- Constant Field Values
infoNames
private static final java.lang.String[] infoNames
Main
public Main()
main
public static void main(java.lang.String[] args)
- Application entry point for SysInfo. This will print out
the Derby product information as well as a snapshot of
the System properties.
getMainInfo
public static void getMainInfo(java.io.PrintWriter aw,
boolean pause)
parseArgs
private static void parseArgs(java.lang.String[] args)
pause
private static void pause()
- For the benefit of DOS box users, this method waits for input
before returning
reportDerby
private static void reportDerby(java.io.PrintWriter localAW)
- prints out the jbms info to the specified AppStreamWriter.
- Parameters:
localAW
- the AppStreamWriter to use. If null, System.out is
used
reportJavaInfo
private static void reportJavaInfo(java.io.PrintWriter localAW)
- Writes out the relevant info about the Java environment to
the specified AppStreamWriter.
- Parameters:
localAW
- The AppStreamWriter to write info out to. If this is
null, the info is written to System.out
printPropertyIfNotNull
private static void printPropertyIfNotNull(java.io.PrintWriter localAW,
java.lang.String property)
- Print property only if not null
- Parameters:
localAW
- This is PrintWriter to print toproperty
- This is system property string
getJavaProperty
private static java.lang.String getJavaProperty(java.lang.String whichProperty)
- Return Java properties from java.lang.System. Will catch
SecurityExceptions and note them for displaying information.
- Parameters:
whichProperty
- This is the name of the property
- Returns:
- getJavaProperty(whichProperty, false)
getJavaProperty
private static java.lang.String getJavaProperty(java.lang.String whichProperty,
boolean nullUnavailable)
- Return Java properties from java.lang.System. Will catch
SecurityExceptions and note them for displaying information.
- Parameters:
whichProperty
- This is the name of the propertynullUnavailable
- return nothing if no such java property and nullUnavailable is true
- Returns:
- the Java property value or a string capturing a
security exception.
getClasspathInfo
private static void getClasspathInfo(java.lang.String[] args,
java.io.PrintWriter aw)
reportLocales
private static void reportLocales(java.io.PrintWriter localAW)
- Writes out information about the locales with the
product.
- Parameters:
localAW
- the AppStreamWriter to which the info is written. If this
value is null, the info is written to System.out
useMe
static void useMe(java.lang.String[] args,
java.io.PrintWriter pw)
tryAllClasspaths
private static void tryAllClasspaths(java.io.PrintWriter localPW)
throws java.lang.Throwable
- Throws:
java.lang.Throwable
trySomeClasspaths
private static void trySomeClasspaths(java.lang.String[] args,
java.io.PrintWriter localPW)
throws java.lang.Throwable
- Throws:
java.lang.Throwable
tryCoreClasspath
private static void tryCoreClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
tryNetClasspath
private static void tryNetClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
tryClientClasspath
private static void tryClientClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
tryDB2DriverClasspath
private static void tryDB2DriverClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
tryUtilsClasspath
private static void tryUtilsClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
tryMyClasspath
private static void tryMyClasspath(java.lang.String cn,
java.lang.String library,
java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
tryAsResource
private static void tryAsResource(java.lang.String cn,
java.lang.String library,
java.lang.StringBuffer successes,
java.lang.StringBuffer failures)
found
private static java.lang.String found(java.lang.String cn,
java.lang.String library,
java.lang.String loc)
notFound
private static java.lang.String notFound(java.lang.String cn,
java.lang.String library)
crLf
private static java.lang.String crLf()
lookForMainArg
private static java.lang.String lookForMainArg(java.lang.String[] args,
java.io.PrintWriter localPW)
argumentsContain
private static boolean argumentsContain(java.lang.String[] args,
java.lang.String s)
argumentMatches
private static java.lang.String argumentMatches(java.lang.String[] args,
java.lang.String ss)
getAllInfo
public static ZipInfoProperties[] getAllInfo(java.lang.String classpath)
- Get all the info we can obtain from the local execution context
as to the availability of the Derby classes by attempting to load
the info files with loadZipFromResource() and checking classpath
locations with checkForInfo if the classpath is accessible.
- Parameters:
classpath
- the classpath, or null if not accessible
- Returns:
- an array of ZipInfoProperties with the locations of the located
resources
- See Also:
loadZipFromResource()
,
checkForInfo(String)
loadZipFromResource
private static ZipInfoProperties[] loadZipFromResource()
- Attempt to load the info properties files specified in infoNames[i]
using getResourceAsStream(). If none are able to be loaded, return
a null array.
- Returns:
- An array of ZipInfoProperties with the locations from which
the info properties files were loaded.
- See Also:
infoNames
parseClasspath
private static java.lang.String[] parseClasspath(java.lang.String cp)
- Split the classpath into separate elements.
- Parameters:
cp
- the classpath, if accessible.
- Returns:
- a String array with the individual classpath elements.
checkForInfo
private static ZipInfoProperties checkForInfo(java.lang.String cpEntry)
- Given an individual element of the element of the classpath, call
checkDirectory() if the element is a directory or checkFile()
if the element is a file.
- Parameters:
cpEntry
- the classpath element
- Returns:
- a ZipInfoProperties if an info properties file is found.
checkDirectory
private static ZipInfoProperties checkDirectory(java.lang.String dirname)
- Check a given directory for the presence of an info properties file in
org/apache/derby/info inside the directory.
- Parameters:
dirname
- the directory to check as a String
- Returns:
- a ZipInfoProperties if a file is found, otherwise null.
checkFile
private static ZipInfoProperties checkFile(java.lang.String filename)
- Check inside a jar file for the presence of a Derby info properties
file. There is a special case for db2jcc, which does not have a Derby
info propeties file. If db2jcc is in the filename, acquire DB2Driver
via reflection and get the version number from it.
- Parameters:
filename
- the jar file to check
- Returns:
- ZipInfoProperties with the jar file set as the location
or null if not found.
getTextMessage
public static java.lang.String getTextMessage(java.lang.String msgId)
getTextMessage
public static java.lang.String getTextMessage(java.lang.String msgId,
java.lang.Object a1)
getTextMessage
public static java.lang.String getTextMessage(java.lang.String msgId,
java.lang.Object a1,
java.lang.Object a2)
getTextMessage
public static java.lang.String getTextMessage(java.lang.String msgId,
java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3)
getTextMessage
public static java.lang.String getTextMessage(java.lang.String msgId,
java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3,
java.lang.Object a4)
getCompleteMessage
public static java.lang.String getCompleteMessage(java.lang.String msgId,
java.lang.Object[] arguments)
getFileWhichLoadedClass
private static java.lang.String getFileWhichLoadedClass(java.lang.Class cls)
- Given a loaded class, this
routine asks the class's class loader for information about where the
class was loaded from. Typically, this is a file, which might be
either a class file or a jar file. The routine figures that out, and
returns the name of the file. If it can't figure it out, it returns null
mergeZips
private static ZipInfoProperties[] mergeZips(ZipInfoProperties[] zip1,
ZipInfoProperties[] zip2)
Merge and flatten two arrays of ZipInfoProperties, removing any
duplicates. There may be duplicates in the arrays because
loadZipFromResource may find all the properties files in the same
location, such as when loading from compiled source instead of
packaged jars. Also, a poorly constructed classpath may contain
duplicate entries that each contain the Derby classes, and we
need only report the first of each such instances found.
The second array may be null if the classpath was empty, in which
case we still remove the duplicates from the first array and return
the shortened array.
- Parameters:
zip1
- the first array from loadZipWithResourcezip2
- the second array from analyzing the classpath
- Returns:
- the merged array
formatURL
private static java.lang.String formatURL(java.net.URL loc)
- Strip a given URL down to the filename. The URL will be a jarfile or
directory containing a Derby info properties file. Return the canonical
path for the filename, with the path separators normalized.
Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.