public final class Main
extends java.lang.Object
Sysinfo reports values relevant to the current Derby configuration.
Sysinfo looks for properties files in org.apache.derby.info named after
the genus names in org.apache.derby.tools.sysinfo, and gets their location
using getResource. It also searches the classpath and attempts to load
the info properties files from the directory or jar locations on the
classpath, and eliminates any duplicated information. If no files
are found, or some other exception occurs, the
value returned will be "
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();
Modifier and Type | Field | Description |
---|---|---|
private static java.lang.String |
CLIENT |
|
private static boolean |
cptester |
|
private static java.lang.String |
curLoc |
|
private static java.lang.String |
EMBEDDED |
|
private static java.lang.String[] |
infoNames |
|
private static java.lang.String[] |
jarNames |
|
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 | Description |
---|---|
Main() |
Modifier and Type | Method | Description |
---|---|---|
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 java.lang.String |
getCanonicalPath(java.io.File f) |
wrapper for getCanonicalPath for sysinfo.
|
private static void |
getClasspathInfo(java.lang.String[] args,
java.io.PrintWriter aw) |
|
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,
java.lang.Object... arguments) |
|
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 |
reportTesting(java.io.PrintWriter localAW) |
Writes out information about the derbyTesting classes 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 |
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 |
tryTstingClasspath(java.lang.StringBuffer successes,
java.lang.StringBuffer failures) |
|
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) |
private static final java.lang.String MESSAGE_FILE
private static final LocalizedResource LOCALIZED_RESOURCE
main()
.private static boolean setPause
private static boolean setLicense
private static boolean cptester
private static final java.lang.String sep
private static final java.lang.String javaSep
private static final java.lang.String jbmsSep
private static final java.lang.String licSep
private static final java.lang.String locSep
private static final java.lang.String curLoc
private static final java.lang.String EMBEDDED
private static final java.lang.String TOOLS
private static final java.lang.String NET
private static final java.lang.String CLIENT
private static final java.lang.String MAINUSAGESTRING
private static final java.lang.String USAGESTRINGPARTA
private static final java.lang.String USAGESTRINGPARTB
private static final java.lang.String[] infoNames
private static final java.lang.String[] jarNames
public static void main(java.lang.String[] args)
public static void getMainInfo(java.io.PrintWriter aw, boolean pause)
private static void parseArgs(java.lang.String[] args)
private static void pause()
private static void reportDerby(java.io.PrintWriter localAW)
localAW
- the AppStreamWriter to use. If null, System.out is
usedprivate static void reportJavaInfo(java.io.PrintWriter localAW)
localAW
- The AppStreamWriter to write info out to. If this is
null, the info is written to System.outprivate static void printPropertyIfNotNull(java.io.PrintWriter localAW, java.lang.String property)
localAW
- This is PrintWriter to print toproperty
- This is system property stringprivate static java.lang.String getJavaProperty(java.lang.String whichProperty)
whichProperty
- This is the name of the propertyprivate static java.lang.String getJavaProperty(java.lang.String whichProperty, boolean nullUnavailable)
whichProperty
- This is the name of the propertynullUnavailable
- return nothing if no such java property and nullUnavailable is trueprivate static java.lang.String getCanonicalPath(java.io.File f) throws java.io.IOException
f
- file on which to call getCanonicalPathjava.io.IOException
private static void getClasspathInfo(java.lang.String[] args, java.io.PrintWriter aw)
private static void reportLocales(java.io.PrintWriter localAW)
localAW
- the AppStreamWriter to which the info is written. If this
value is null, the info is written to System.outprivate static void reportTesting(java.io.PrintWriter localAW)
localAW
- the AppStreamWriter to which the info is written. If this
value is null, the info is written to System.outstatic void useMe(java.lang.String[] args, java.io.PrintWriter pw)
private static void tryAllClasspaths(java.io.PrintWriter localPW) throws java.lang.Throwable
java.lang.Throwable
private static void trySomeClasspaths(java.lang.String[] args, java.io.PrintWriter localPW) throws java.lang.Throwable
java.lang.Throwable
private static void tryCoreClasspath(java.lang.StringBuffer successes, java.lang.StringBuffer failures)
private static void tryNetClasspath(java.lang.StringBuffer successes, java.lang.StringBuffer failures)
private static void tryClientClasspath(java.lang.StringBuffer successes, java.lang.StringBuffer failures)
private static void tryUtilsClasspath(java.lang.StringBuffer successes, java.lang.StringBuffer failures)
private static void tryTstingClasspath(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 tryAsResource(java.lang.String cn, java.lang.String library, java.lang.StringBuffer successes, java.lang.StringBuffer failures)
private static java.lang.String found(java.lang.String cn, java.lang.String library, java.lang.String loc)
private static java.lang.String notFound(java.lang.String cn, java.lang.String library)
private static java.lang.String crLf()
private static java.lang.String lookForMainArg(java.lang.String[] args, java.io.PrintWriter localPW)
private static boolean argumentsContain(java.lang.String[] args, java.lang.String s)
private static java.lang.String argumentMatches(java.lang.String[] args, java.lang.String ss)
public static ZipInfoProperties[] getAllInfo(java.lang.String classpath)
classpath
- the classpath, or null if not accessibleloadZipFromResource()
,
checkForInfo(String)
private static ZipInfoProperties[] loadZipFromResource()
infoNames
private static java.lang.String[] parseClasspath(java.lang.String cp)
cp
- the classpath, if accessible.private static ZipInfoProperties checkForInfo(java.lang.String cpEntry)
cpEntry
- the classpath elementprivate static ZipInfoProperties checkDirectory(java.lang.String dirname)
dirname
- the directory to check as a Stringprivate static ZipInfoProperties checkFile(java.lang.String filename)
filename
- the jar file to checkpublic static java.lang.String getTextMessage(java.lang.String msgId, java.lang.Object... arguments)
private static java.lang.String getFileWhichLoadedClass(java.lang.Class cls)
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.
zip1
- the first array from loadZipWithResourcezip2
- the second array from analyzing the classpathprivate static java.lang.String formatURL(java.net.URL loc)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.