changeset 31497 | 4a6b2e733c0d |
parent 25868 | 686eef1e7a79 |
child 44797 | 8b3b3b911b8a |
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/Extensions.java Wed Jul 05 20:39:43 2017 +0200 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/Extensions.java Tue Jun 30 12:04:27 2015 +0200 @@ -22,20 +22,16 @@ */ package com.sun.org.apache.xalan.internal.lib; -import java.util.Hashtable; import java.util.StringTokenizer; -import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; -import com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck; import com.sun.org.apache.xpath.internal.NodeSet; import com.sun.org.apache.xpath.internal.objects.XBoolean; import com.sun.org.apache.xpath.internal.objects.XNumber; import com.sun.org.apache.xpath.internal.objects.XObject; -import com.sun.org.apache.xalan.internal.utils.ObjectFactory; import org.w3c.dom.Document; import org.w3c.dom.DocumentFragment; @@ -275,102 +271,6 @@ return tokenize(toTokenize, " \t\n\r"); } - /** - * Return a Node of basic debugging information from the - * EnvironmentCheck utility about the Java environment. - * - * <p>Simply calls the {@link com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck} - * utility to grab info about the Java environment and CLASSPATH, - * etc., and then returns the resulting Node. Stylesheets can - * then maniuplate this data or simply xsl:copy-of the Node. Note - * that we first attempt to load the more advanced - * org.apache.env.Which utility by reflection; only if that fails - * to we still use the internal version. Which is available from - * <a href="http://xml.apache.org/commons/">http://xml.apache.org/commons/</a>.</p> - * - * <p>We throw a WrappedRuntimeException in the unlikely case - * that reading information from the environment throws us an - * exception. (Is this really the best thing to do?)</p> - * - * @param myContext an <code>ExpressionContext</code> passed in by the - * extension mechanism. This must be an XPathContext. - * @return a Node as described above. - */ - public static Node checkEnvironment(ExpressionContext myContext) - { - - Document factoryDocument = getDocument(); - - Node resultNode = null; - try - { - // First use reflection to try to load Which, which is a - // better version of EnvironmentCheck - resultNode = checkEnvironmentUsingWhich(myContext, factoryDocument); - - if (null != resultNode) - return resultNode; - - // If reflection failed, fallback to our internal EnvironmentCheck - EnvironmentCheck envChecker = new EnvironmentCheck(); - Hashtable h = envChecker.getEnvironmentHash(); - resultNode = factoryDocument.createElement("checkEnvironmentExtension"); - envChecker.appendEnvironmentReport(resultNode, factoryDocument, h); - envChecker = null; - } - catch(Exception e) - { - throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e); - } - - return resultNode; - } - - /** - * Private worker method to attempt to use org.apache.env.Which. - * - * @param myContext an <code>ExpressionContext</code> passed in by the - * extension mechanism. This must be an XPathContext. - * @param factoryDocument providing createElement services, etc. - * @return a Node with environment info; null if any error - */ - private static Node checkEnvironmentUsingWhich(ExpressionContext myContext, - Document factoryDocument) - { - final String WHICH_CLASSNAME = "org.apache.env.Which"; - final String WHICH_METHODNAME = "which"; - final Class WHICH_METHOD_ARGS[] = { java.util.Hashtable.class, - java.lang.String.class, - java.lang.String.class }; - try - { - // Use reflection to try to find xml-commons utility 'Which' - Class clazz = ObjectFactory.findProviderClass(WHICH_CLASSNAME, true); - if (null == clazz) - return null; - - // Fully qualify names since this is the only method they're used in - java.lang.reflect.Method method = clazz.getMethod(WHICH_METHODNAME, WHICH_METHOD_ARGS); - Hashtable report = new Hashtable(); - - // Call the method with our Hashtable, common options, and ignore return value - Object[] methodArgs = { report, "XmlCommons;Xalan;Xerces;Crimson;Ant", "" }; - Object returnValue = method.invoke(null, methodArgs); - - // Create a parent to hold the report and append hash to it - Node resultNode = factoryDocument.createElement("checkEnvironmentExtension"); - com.sun.org.apache.xml.internal.utils.Hashtree2Node.appendHashToNode(report, "whichReport", - resultNode, factoryDocument); - - return resultNode; - } - catch (Throwable t) - { - // Simply return null; no need to report error - return null; - } - } - /** * @return an instance of DOM Document */