org.apache.env
Class Which
public class Which
extends java.lang.Object
General environment checking and version finding service.
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);
Original credit to org.apache.xalan.xslt.EnvironmentCheck
Version:
- shane_curcuru@us.ibm.com
void | doMain(String[] args) - Instance worker method to handle main().
|
static void | getGeneralInfo(Hashtable hash, String options) - Grab a couple of generally useful items, like classpath,
java version, version of this file, etc..
|
static int | getProjectsInfo(Hashtable hash, String projects, String options) - Get information from various project's WhichProject impls.
|
static String | getVersion() - Get simple version info about org.apache.env.Which and
related classes.
|
static void | main(String[] args) - Command line runnability.
|
protected boolean | parseArgs(String[] args) - Parse commandline args, return false if help asked for.
|
protected void | reportHashtable(Hashtable hash, String name, PrintWriter out) - Print information from a hashtable into the PrintWriter.
|
void | reportProjectsInfo(Hashtable hash, String options, int status, PrintWriter out) - Print information from which() into the PrintWriter.
|
protected String | usage() - Return our usage statement.
|
static int | which(Hashtable hash, String projects, String options) - Which - get all info.
|
DEFAULT_PROJECTS
public static final String DEFAULT_PROJECTS
Default set of projects to use if none provided.
SEPARATOR
public static final String SEPARATOR
Generic ';' separator for various items.
optionsBuf
protected StringBuffer optionsBuf
optionsBuf.
outWriter
protected PrintWriter outWriter
outWriter.
projectsBuf
protected StringBuffer projectsBuf
projectsBuf.
doMain
public void doMain(String[] args)
Instance worker method to handle main().
args
- command line args
getGeneralInfo
public static void getGeneralInfo(Hashtable hash,
String options)
Grab a couple of generally useful items, like classpath,
java version, version of this file, etc..
hash
- to put information in
getProjectsInfo
public static int getProjectsInfo(Hashtable hash,
String projects,
String options)
Get information from various project's WhichProject impls.
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
- status information from WhichConstant
getVersion
public static String getVersion()
Get simple version info about org.apache.env.Which and
related classes.
- String of our file version
main
public static void main(String[] args)
Command line runnability.
args
- command line args
parseArgs
protected boolean parseArgs(String[] args)
Parse commandline args, return false if help asked for.
args
- array of commandline args
- true if OK, false if error/usage/help needed
reportHashtable
protected void reportHashtable(Hashtable hash,
String name,
PrintWriter out)
Print information from a hashtable into the PrintWriter.
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 to
reportProjectsInfo
public void reportProjectsInfo(Hashtable hash,
String options,
int status,
PrintWriter out)
Print information from which() into the PrintWriter.
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 to
usage
protected String usage()
Return our usage statement.
- String of our usage
which
public static int which(Hashtable hash,
String projects,
String options)
Which - get all info.
Worker method called from doMain or suitable for calling
from other programs.
hash
- to put information inprojects
- to get information aboutoptions
- to apply like strict or verbose
- status information from WhichConstant
Copyright B) 2001 Apache. All Rights Reserved.