org.apache.env

Class Which

public class Which extends 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: $Id: Which.java 225940 2001-12-21 22:59:05Z curcuru $

Author: shane_curcuru@us.ibm.com

Field Summary
static StringDEFAULT_PROJECTS
Default set of projects to use if none provided.
protected StringBufferoptionsBuf
optionsBuf.
protected PrintWriteroutWriter
outWriter.
protected StringBufferprojectsBuf
projectsBuf.
static StringSEPARATOR
Generic ';' separator for various items.
Method Summary
voiddoMain(String[] args)
Instance worker method to handle main().
static voidgetGeneralInfo(Hashtable hash, String options)
Grab a couple of generally useful items, like classpath, java version, version of this file, etc..
static intgetProjectsInfo(Hashtable hash, String projects, String options)
Get information from various project's WhichProject impls.
static StringgetVersion()
Get simple version info about org.apache.env.Which and related classes.
static voidmain(String[] args)
Command line runnability.
protected booleanparseArgs(String[] args)
Parse commandline args, return false if help asked for.
protected voidreportHashtable(Hashtable hash, String name, PrintWriter out)
Print information from a hashtable into the PrintWriter.
voidreportProjectsInfo(Hashtable hash, String options, int status, PrintWriter out)
Print information from which() into the PrintWriter.
protected Stringusage()
Return our usage statement.
static intwhich(Hashtable hash, String projects, String options)
Which - get all info.

Field Detail

DEFAULT_PROJECTS

public static final String DEFAULT_PROJECTS
Default set of projects to use if none provided.

optionsBuf

protected StringBuffer optionsBuf
optionsBuf.

outWriter

protected PrintWriter outWriter
outWriter.

projectsBuf

protected StringBuffer projectsBuf
projectsBuf.

SEPARATOR

public static final String SEPARATOR
Generic ';' separator for various items.

Method Detail

doMain

public void doMain(String[] args)
Instance worker method to handle main().

Parameters: 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..

Parameters: hash to put information in projects to get information about

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.

Parameters: hash to put information in projects to get information about options to apply like strict or verbose

Returns: status information from WhichConstant

getVersion

public static String getVersion()
Get simple version info about org.apache.env.Which and related classes.

Returns: String of our file version

main

public static void main(String[] args)
Command line runnability.

Parameters: args command line args

parseArgs

protected boolean parseArgs(String[] args)
Parse commandline args, return false if help asked for.

Parameters: args array of commandline args

Returns: 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.

Parameters: hash to get info from (may have subhashtables) name to print as header for this hash out 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.

Parameters: hash to get info from (may have subhashtables) options to apply like strict or verbose status from finding version info out PrintWriter to send Properties.list()-like output to

usage

protected String usage()
Return our usage statement.

Returns: 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.

Parameters: hash to put information in projects to get information about options to apply like strict or verbose

Returns: status information from WhichConstant

Copyright B) 2001 Apache. All Rights Reserved.