|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xalan.xslt.EnvironmentCheck
public class EnvironmentCheck
Utility class to report simple information about the environment. Simplistic reporting about certain classes found in your JVM may help answer some FAQs for simple problems.
Usage-command line:
java org.apache.xalan.xslt.EnvironmentCheck [-out outFile]
Usage-from program:
boolean environmentOK =
(new EnvironmentCheck()).checkEnvironment(yourPrintWriter);
Usage-from stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
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>
Xalan users reporting problems are encouraged to use this class to see if there are potential problems with their actual Java environment before reporting a bug. Note that you should both check from the JVM/JRE's command line as well as temporarily calling checkEnvironment() directly from your code, since the classpath may differ (especially for servlets, etc).
Also see http://xml.apache.org/xalan-j/faq.html
Note: This class is pretty simplistic: results are not necessarily definitive nor will it find all problems related to environment setup. Also, you should avoid calling this in deployed production code, both because it is quite slow and because it forces classes to get loaded.
Note: This class explicitly has very limited compile-time dependencies to enable easy compilation and usage even when Xalan, DOM/SAX/JAXP, etc. are not present.
Note: for an improved version of this utility, please see the xml-commons' project Which utility which does the same kind of thing but in a much simpler manner.
Field Summary | |
---|---|
static java.lang.String |
CLASS_NOTPRESENT
Marker that a class or .jar was not found. |
static java.lang.String |
CLASS_PRESENT
Marker that a class or .jar was found. |
static java.lang.String |
ERROR
Prefixed to hash keys that signify serious problems. |
static java.lang.String |
ERROR_FOUND
Value for any error found. |
static java.lang.String |
FOUNDCLASSES
Prefixed to hash keys that signify .jars found in classpath. |
java.lang.String[] |
jarNames
Listing of common .jar files that include Xalan-related classes. |
private static java.util.Hashtable |
jarVersions
Manual table of known .jar sizes. |
protected java.io.PrintWriter |
outWriter
Simple PrintWriter we send output to; defaults to System.out. |
static java.lang.String |
VERSION
Prefixed to hash keys that signify version numbers. |
static java.lang.String |
WARNING
Added to descriptions that signify potential problems. |
Constructor Summary | |
---|---|
EnvironmentCheck()
|
Method Summary | |
---|---|
void |
appendEnvironmentReport(org.w3c.dom.Node container,
org.w3c.dom.Document factory,
java.util.Hashtable h)
Stylesheet extension entrypoint: Dump a basic Xalan environment report from getEnvironmentHash() to a Node. |
protected boolean |
appendFoundJars(org.w3c.dom.Node container,
org.w3c.dom.Document factory,
java.util.Vector v,
java.lang.String desc)
Print out report of .jars found in a classpath. |
protected void |
checkAntVersion(java.util.Hashtable h)
Report product version information from Ant. |
protected void |
checkDOMVersion(java.util.Hashtable h)
Report version info from DOM interfaces. |
boolean |
checkEnvironment(java.io.PrintWriter pw)
Programmatic entrypoint: Report on basic Java environment and CLASSPATH settings that affect Xalan. |
protected void |
checkJAXPVersion(java.util.Hashtable h)
Report version information about JAXP interfaces. |
protected void |
checkParserVersion(java.util.Hashtable h)
Report product version information from common parsers. |
protected java.util.Vector |
checkPathForJars(java.lang.String cp,
java.lang.String[] jars)
Cheap-o listing of specified .jars found in the classpath. |
protected void |
checkProcessorVersion(java.util.Hashtable h)
Report product version information from Xalan-J. |
protected void |
checkSAXVersion(java.util.Hashtable h)
Report version info from SAX interfaces. |
protected void |
checkSystemProperties(java.util.Hashtable h)
Fillin hash with info about SystemProperties. |
protected java.lang.String |
getApparentVersion(java.lang.String jarName,
long jarSize)
Cheap-o method to determine the product version of a .jar. |
java.util.Hashtable |
getEnvironmentHash()
Fill a hash with basic environment settings that affect Xalan. |
protected boolean |
logFoundJars(java.util.Vector v,
java.lang.String desc)
Print out report of .jars found in a classpath. |
protected void |
logMsg(java.lang.String s)
Bottleneck output: calls outWriter.println(s). |
static void |
main(java.lang.String[] args)
Command line runnability: checks for [-out outFilename] arg. |
protected boolean |
writeEnvironmentReport(java.util.Hashtable h)
Dump a basic Xalan environment report to outWriter. |
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 ERROR
public static final java.lang.String WARNING
public static final java.lang.String ERROR_FOUND
public static final java.lang.String VERSION
public static final java.lang.String FOUNDCLASSES
public static final java.lang.String CLASS_PRESENT
public static final java.lang.String CLASS_NOTPRESENT
public java.lang.String[] jarNames
private static java.util.Hashtable jarVersions
getApparentVersion(String, long)
protected java.io.PrintWriter outWriter
Constructor Detail |
---|
public EnvironmentCheck()
Method Detail |
---|
public static void main(java.lang.String[] args)
Command line entrypoint; Sets output and calls
checkEnvironment(PrintWriter)
.
args
- command line argspublic boolean checkEnvironment(java.io.PrintWriter pw)
Note that this class is not advanced enough to tell you everything about the environment that affects Xalan, and sometimes reports errors that will not actually affect Xalan's behavior. Currently, it very simplistically checks the JVM's environment for some basic properties and logs them out; it will report a problem if it finds a setting or .jar file that is likely to cause problems.
Advanced users can peruse the code herein to help them investigate potential environment problems found; other users may simply send the output from this tool along with any bugs they submit to help us in the debugging process.
pw
- PrintWriter to send output to; can be sent to a
file that will look similar to a Properties file; defaults
to System.out if null
getEnvironmentHash()
public java.util.Hashtable getEnvironmentHash()
Worker method called from various places.
Various system and CLASSPATH, etc. properties are put into
the hash as keys with a brief description of the current state
of that item as the value. Any serious problems will be put in
with a key that is prefixed with 'ERROR.'
so it
stands out in any resulting report; also a key with just that
constant will be set as well for any error.
Note that some legitimate cases are flaged as potential errors - namely when a developer recompiles xalan.jar on their own - and even a non-error state doesn't guaruntee that everything in the environment is correct. But this will help point out the most common classpath and system property problems that we've seen.
protected boolean writeEnvironmentReport(java.util.Hashtable h)
This dumps a simple header and then each of the entries in the Hashtable to our PrintWriter; it does special processing for entries that are .jars found in the classpath.
h
- Hashtable of items to report on; presumably
filled in by our various check*() methods
for an equivalent that appends to a Node instead
protected boolean logFoundJars(java.util.Vector v, java.lang.String desc)
v
- Vector of Hashtables of .jar file infodesc
- description to print out in header
checkPathForJars(String, String[])
public void appendEnvironmentReport(org.w3c.dom.Node container, org.w3c.dom.Document factory, java.util.Hashtable h)
Copy of writeEnvironmentReport that creates a Node suitable for other processing instead of a properties-like text output.
container
- Node to append our report tofactory
- Document providing createElement, etc. servicesh
- Hash presumably from getEnvironmentHash()
for an equivalent that writes to a PrintWriter instead
protected boolean appendFoundJars(org.w3c.dom.Node container, org.w3c.dom.Document factory, java.util.Vector v, java.lang.String desc)
container
- Node to append our report tofactory
- Document providing createElement, etc. servicesv
- Vector of Hashtables of .jar file infodesc
- description to print out in header
checkPathForJars(String, String[])
protected void checkSystemProperties(java.util.Hashtable h)
h
- Hashtable to put information injarNames
,
checkPathForJars(String, String[])
protected java.util.Vector checkPathForJars(java.lang.String cp, java.lang.String[] jars)
cp
- classpath to searchjars
- array of .jar base filenames to look for
jarNames
,
logFoundJars(Vector, String)
,
appendFoundJars(Node, Document, Vector, String )
,
getApparentVersion(String, long)
protected java.lang.String getApparentVersion(java.lang.String jarName, long jarSize)
jarName
- base filename of the .jarfilejarSize
- size of the .jarfile
protected void checkJAXPVersion(java.util.Hashtable h)
h
- Hashtable to put information inprotected void checkProcessorVersion(java.util.Hashtable h)
h
- Hashtable to put information inprotected void checkParserVersion(java.util.Hashtable h)
h
- Hashtable to put information inprotected void checkAntVersion(java.util.Hashtable h)
h
- Hashtable to put information inprotected void checkDOMVersion(java.util.Hashtable h)
h
- Hashtable to put information inprotected void checkSAXVersion(java.util.Hashtable h)
h
- Hashtable to put information inprotected void logMsg(java.lang.String s)
s
- String to print
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |