|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.env.Which
General environment checking and version finding service; main external entrypoints and command line interface.
Which is the command line interface to the org.apache.env package. Simply put, it provides a simplistic check of a user's actual environment for debugging and product support purposes by detecting the specific versions of commonly installed classes in the environment.
Which and related service classes provide a framework for looking for version information and passing it around in hashtables. Users can plug in their own implementations of WhichProject classes to get custom version info about any product.
One important usage note: you must call Which (or subclasses) in the environment that you wish to check. I.e. if you have a problem with a command line tool, then call Which from the same command line environment. If you have a problem with a servlet, you must call Which.blah() from your servlet as it's installed in an actual container.
Usage - command line:
java org.apache.env.Which [project;WhichProject] [-options]
Usage - from program:
int status = org.apache.env.Which.which(hash, projects, options);
Usage - from XSLT stylesheet in Xalan-J:
(add which.jar to your classpath and run the following stylesheet)
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan"> <xsl:output indent="yes"/> <xsl:template match="/"> <xsl:copy-of select="xalan:checkEnvironment()"/> </xsl:template> </xsl:stylesheet>
Original credit to org.apache.xalan.xslt.EnvironmentCheck
Field Summary | |
static java.lang.String |
DEFAULT_PROJECTS
Default set of projects to use if none provided. |
protected java.lang.StringBuffer |
optionsBuf
optionsBuf. |
protected java.io.PrintWriter |
outWriter
outWriter. |
protected java.lang.StringBuffer |
projectsBuf
projectsBuf. |
static java.lang.String |
SEPARATOR
Generic ';' separator for various items. |
Constructor Summary | |
Which()
|
Method Summary | |
void |
doMain(java.lang.String[] args)
Instance worker method to handle main(). |
static void |
getGeneralInfo(java.util.Hashtable hash,
java.lang.String options)
Grab a couple of generally useful items, like classpath, java version, version of this file, etc.. |
static int |
getProjectsInfo(java.util.Hashtable hash,
java.lang.String projects,
java.lang.String options)
Get information from various project's WhichProject impls. |
static java.lang.String |
getVersion()
Get simple version info about org.apache.env.Which and related classes. |
static void |
main(java.lang.String[] args)
Command line runnability. |
protected boolean |
parseArgs(java.lang.String[] args)
Parse commandline args, return false if help asked for. |
protected void |
reportHashtable(java.util.Hashtable hash,
java.lang.String name,
java.io.PrintWriter out)
Print information from a hashtable into the PrintWriter. |
void |
reportProjectsInfo(java.util.Hashtable hash,
java.lang.String options,
int status,
java.io.PrintWriter out)
Print information from which() into the PrintWriter. |
protected java.lang.String |
usage()
Return our usage statement. |
static int |
which(java.util.Hashtable hash,
java.lang.String projects,
java.lang.String options)
Which - get all info. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String SEPARATOR
public static final java.lang.String DEFAULT_PROJECTS
protected java.lang.StringBuffer optionsBuf
protected java.lang.StringBuffer projectsBuf
protected java.io.PrintWriter outWriter
Constructor Detail |
public Which()
Method Detail |
public static void main(java.lang.String[] args)
args
- command line argspublic void doMain(java.lang.String[] args)
args
- command line argspublic static int which(java.util.Hashtable hash, java.lang.String projects, java.lang.String options)
hash
- to put information inprojects
- to get information aboutoptions
- to apply like strict or verbose
public static void getGeneralInfo(java.util.Hashtable hash, java.lang.String options)
hash
- to put information inpublic static int getProjectsInfo(java.util.Hashtable hash, java.lang.String projects, java.lang.String options)
Each project's info is put into a subhash. Note: if projects is null, we use DEFAULT_PROJECTS.
hash
- to put information inprojects
- to get information aboutoptions
- to apply like strict or verbose
public void reportProjectsInfo(java.util.Hashtable hash, java.lang.String options, int status, java.io.PrintWriter out)
Simplistic implementation to report to a writer.
hash
- to get info from (may have subhashtables)options
- to apply like strict or verbosestatus
- from finding version infoout
- PrintWriter to send Properties.list()-like
output toprotected void reportHashtable(java.util.Hashtable hash, java.lang.String name, java.io.PrintWriter out)
Provides a pre-order traversal where the parent hash has it's output dumped before recursing to any child sub hashes. Sorta looks like Properties.list() output.
hash
- to get info from (may have subhashtables)name
- to print as header for this hashout
- PrintWriter to send Properties.list()-like
output toprotected java.lang.String usage()
protected boolean parseArgs(java.lang.String[] args)
args
- array of commandline args
public static java.lang.String getVersion()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |