8013434: Xalan and Xerces internal ObjectFactory need rework
Summary: With this changeset, DTMManager and XSLTCDTMManager will always use their own default implementation.
Reviewed-by: joehw, alanb
--- a/jaxp/src/com/sun/org/apache/xalan/META-INF/services/javax.xml.transform.TransformerFactory Thu Jun 06 20:40:43 2013 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
--- a/jaxp/src/com/sun/org/apache/xalan/META-INF/services/javax.xml.xpath.XPathFactory Thu Jun 06 20:40:43 2013 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl
\ No newline at end of file
--- a/jaxp/src/com/sun/org/apache/xalan/META-INF/services/org.apache.xml.dtm.DTMManager Thu Jun 06 20:40:43 2013 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault
--- a/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java Thu Jun 06 20:47:13 2013 +0200
@@ -23,26 +23,11 @@
package com.sun.org.apache.xalan.internal.utils;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-
-import java.util.Properties;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
/**
* This class is duplicated for each JAXP subpackage so keep it in sync.
* It is package private and therefore is not exposed as part of the JAXP
* API.
* <p>
- * This code is designed to implement the JAXP 1.1 spec pluggability
- * feature and is designed to run on JDK version 1.1 and
- * later, and to compile on JDK 1.2 and onward.
- * The code also runs both as part of an unbundled jar file and
- * when bundled as part of the JDK.
- * <p>
* This class was moved from the <code>javax.xml.parsers.ObjectFactory</code>
* class and modified to be used as a general utility for creating objects
* dynamically.
@@ -57,329 +42,9 @@
private static final String XALAN_INTERNAL = "com.sun.org.apache.xalan.internal";
private static final String XERCES_INTERNAL = "com.sun.org.apache.xerces.internal";
- // name of default properties file to look for in JDK's jre/lib directory
- private static final String DEFAULT_PROPERTIES_FILENAME =
- "xalan.properties";
-
- private static final String SERVICES_PATH = "META-INF/services/";
-
/** Set to true for debugging */
private static final boolean DEBUG = false;
- /** cache the contents of the xalan.properties file.
- * Until an attempt has been made to read this file, this will
- * be null; if the file does not exist or we encounter some other error
- * during the read, this will be empty.
- */
- private static Properties fXalanProperties = null;
-
- /***
- * Cache the time stamp of the xalan.properties file so
- * that we know if it's been modified and can invalidate
- * the cache when necessary.
- */
- private static long fLastModified = -1;
-
- //
- // Public static methods
- //
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return instance of factory, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- public static Object createObject(String factoryId, String fallbackClassName)
- throws ConfigurationError {
- return createObject(factoryId, null, fallbackClassName);
- } // createObject(String,String):Object
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return instance of factory, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param propertiesFilename The filename in the $java.home/lib directory
- * of the properties file. If none specified,
- * ${java.home}/lib/xalan.properties will be used.
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- static Object createObject(String factoryId,
- String propertiesFilename,
- String fallbackClassName)
- throws ConfigurationError
- {
- Class factoryClass = lookUpFactoryClass(factoryId,
- propertiesFilename,
- fallbackClassName);
-
- if (factoryClass == null) {
- throw new ConfigurationError(
- "Provider for " + factoryId + " cannot be found", null);
- }
-
- try{
- Object instance = factoryClass.newInstance();
- if (DEBUG) debugPrintln("created new instance of factory " + factoryId);
- return instance;
- } catch (Exception x) {
- throw new ConfigurationError(
- "Provider for factory " + factoryId
- + " could not be instantiated: " + x, x);
- }
- } // createObject(String,String,String):Object
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return Class object of factory, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param propertiesFilename The filename in the $java.home/lib directory
- * of the properties file. If none specified,
- * ${java.home}/lib/xalan.properties will be used.
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- public static Class lookUpFactoryClass(String factoryId)
- throws ConfigurationError
- {
- return lookUpFactoryClass(factoryId, null, null);
- } // lookUpFactoryClass(String):Class
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return Class object that provides factory service, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param propertiesFilename The filename in the $java.home/lib directory
- * of the properties file. If none specified,
- * ${java.home}/lib/xalan.properties will be used.
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- public static Class lookUpFactoryClass(String factoryId,
- String propertiesFilename,
- String fallbackClassName)
- throws ConfigurationError
- {
- String factoryClassName = lookUpFactoryClassName(factoryId,
- propertiesFilename,
- fallbackClassName);
- ClassLoader cl = findClassLoader();
-
- if (factoryClassName == null) {
- factoryClassName = fallbackClassName;
- }
-
- // assert(className != null);
- try{
- Class providerClass = findProviderClass(factoryClassName,
- cl,
- true);
- if (DEBUG) debugPrintln("created new instance of " + providerClass +
- " using ClassLoader: " + cl);
- return providerClass;
- } catch (ClassNotFoundException x) {
- throw new ConfigurationError(
- "Provider " + factoryClassName + " not found", x);
- } catch (Exception x) {
- throw new ConfigurationError(
- "Provider "+factoryClassName+" could not be instantiated: "+x,
- x);
- }
- } // lookUpFactoryClass(String,String,String):Class
-
- /**
- * Finds the name of the required implementation class in the specified
- * order. The specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return name of class that provides factory service, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param propertiesFilename The filename in the $java.home/lib directory
- * of the properties file. If none specified,
- * ${java.home}/lib/xalan.properties will be used.
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- static String lookUpFactoryClassName(String factoryId,
- String propertiesFilename,
- String fallbackClassName)
- {
- // Use the system property first
- try {
- String systemProp = SecuritySupport.getSystemProperty(factoryId);
- if (systemProp != null) {
- if (DEBUG) debugPrintln("found system property, value=" + systemProp);
- return systemProp;
- }
- } catch (SecurityException se) {
- // Ignore and continue w/ next location
- }
-
- // Try to read from propertiesFilename, or
- // $java.home/lib/xalan.properties
- String factoryClassName = null;
- // no properties file name specified; use
- // $JAVA_HOME/lib/xalan.properties:
- if (propertiesFilename == null) {
- File propertiesFile = null;
- boolean propertiesFileExists = false;
- try {
- String javah = SecuritySupport.getSystemProperty("java.home");
- propertiesFilename = javah + File.separator +
- "lib" + File.separator + DEFAULT_PROPERTIES_FILENAME;
- propertiesFile = new File(propertiesFilename);
- propertiesFileExists = SecuritySupport.getFileExists(propertiesFile);
- } catch (SecurityException e) {
- // try again...
- fLastModified = -1;
- fXalanProperties = null;
- }
-
- synchronized (ObjectFactory.class) {
- boolean loadProperties = false;
- FileInputStream fis = null;
- try {
- // file existed last time
- if(fLastModified >= 0) {
- if(propertiesFileExists &&
- (fLastModified < (fLastModified = SecuritySupport.getLastModified(propertiesFile)))) {
- loadProperties = true;
- } else {
- // file has stopped existing...
- if(!propertiesFileExists) {
- fLastModified = -1;
- fXalanProperties = null;
- } // else, file wasn't modified!
- }
- } else {
- // file has started to exist:
- if(propertiesFileExists) {
- loadProperties = true;
- fLastModified = SecuritySupport.getLastModified(propertiesFile);
- } // else, nothing's changed
- }
- if(loadProperties) {
- // must never have attempted to read xalan.properties
- // before (or it's outdeated)
- fXalanProperties = new Properties();
- fis = SecuritySupport.getFileInputStream(propertiesFile);
- fXalanProperties.load(fis);
- }
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
- finally {
- // try to close the input stream if one was opened.
- if (fis != null) {
- try {
- fis.close();
- }
- // Ignore the exception.
- catch (IOException exc) {}
- }
- }
- }
- if(fXalanProperties != null) {
- factoryClassName = fXalanProperties.getProperty(factoryId);
- }
- } else {
- FileInputStream fis = null;
- try {
- fis = SecuritySupport.getFileInputStream(new File(propertiesFilename));
- Properties props = new Properties();
- props.load(fis);
- factoryClassName = props.getProperty(factoryId);
- } catch (Exception x) {
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
- finally {
- // try to close the input stream if one was opened.
- if (fis != null) {
- try {
- fis.close();
- }
- // Ignore the exception.
- catch (IOException exc) {}
- }
- }
- }
- if (factoryClassName != null) {
- if (DEBUG) debugPrintln("found in " + propertiesFilename + ", value="
- + factoryClassName);
- return factoryClassName;
- }
-
- // Try Jar Service Provider Mechanism
- return findJarServiceProviderName(factoryId);
- } // lookUpFactoryClass(String,String):String
-
- //
- // Private static methods
- //
/** Prints a message to standard error if debugging is enabled. */
private static void debugPrintln(String msg) {
@@ -393,7 +58,6 @@
* the context ClassLoader.
*/
public static ClassLoader findClassLoader()
- throws ConfigurationError
{
if (System.getSecurityManager()!=null) {
//this will ensure bootclassloader is used
@@ -452,8 +116,8 @@
} // findClassLoader():ClassLoader
/**
- * Create an instance of a class using the same classloader for the ObjectFactory by default
- * or bootclassloader when Security Manager is in place
+ * Create an instance of a class using the same class loader for the ObjectFactory by default
+ * or boot class loader when Security Manager is in place
*/
public static Object newInstance(String className, boolean doFallback)
throws ConfigurationError
@@ -491,10 +155,10 @@
}
/**
- * Find a Class using the same classloader for the ObjectFactory by default
- * or bootclassloader when Security Manager is in place
+ * Find a Class using the same class loader for the ObjectFactory by default
+ * or boot class loader when Security Manager is in place
*/
- public static Class findProviderClass(String className, boolean doFallback)
+ public static Class<?> findProviderClass(String className, boolean doFallback)
throws ClassNotFoundException, ConfigurationError
{
if (System.getSecurityManager()!=null) {
@@ -508,7 +172,7 @@
/**
* Find a Class using the specified ClassLoader
*/
- static Class findProviderClass(String className, ClassLoader cl,
+ private static Class<?> findProviderClass(String className, ClassLoader cl,
boolean doFallback)
throws ClassNotFoundException, ConfigurationError
{
@@ -531,7 +195,7 @@
throw e;
}
- Class providerClass;
+ Class<?> providerClass;
if (cl == null) {
// XXX Use the bootstrap ClassLoader. There is no way to
// load a class using the bootstrap ClassLoader that works
@@ -567,93 +231,4 @@
return providerClass;
}
- /**
- * Find the name of service provider using Jar Service Provider Mechanism
- *
- * @return instance of provider class if found or null
- */
- private static String findJarServiceProviderName(String factoryId)
- {
- String serviceId = SERVICES_PATH + factoryId;
- InputStream is = null;
-
- // First try the Context ClassLoader
- ClassLoader cl = findClassLoader();
-
- is = SecuritySupport.getResourceAsStream(cl, serviceId);
-
- // If no provider found then try the current ClassLoader
- if (is == null) {
- ClassLoader current = ObjectFactory.class.getClassLoader();
- if (cl != current) {
- cl = current;
- is = SecuritySupport.getResourceAsStream(cl, serviceId);
- }
- }
-
- if (is == null) {
- // No provider found
- return null;
- }
-
- if (DEBUG) debugPrintln("found jar resource=" + serviceId +
- " using ClassLoader: " + cl);
-
- // Read the service provider name in UTF-8 as specified in
- // the jar spec. Unfortunately this fails in Microsoft
- // VJ++, which does not implement the UTF-8
- // encoding. Theoretically, we should simply let it fail in
- // that case, since the JVM is obviously broken if it
- // doesn't support such a basic standard. But since there
- // are still some users attempting to use VJ++ for
- // development, we have dropped in a fallback which makes a
- // second attempt using the platform's default encoding. In
- // VJ++ this is apparently ASCII, which is a subset of
- // UTF-8... and since the strings we'll be reading here are
- // also primarily limited to the 7-bit ASCII range (at
- // least, in English versions), this should work well
- // enough to keep us on the air until we're ready to
- // officially decommit from VJ++. [Edited comment from
- // jkesselm]
- BufferedReader rd;
- try {
- rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- } catch (java.io.UnsupportedEncodingException e) {
- rd = new BufferedReader(new InputStreamReader(is));
- }
-
- String factoryClassName = null;
- try {
- // XXX Does not handle all possible input as specified by the
- // Jar Service Provider specification
- factoryClassName = rd.readLine();
- } catch (IOException x) {
- // No provider found
- return null;
- }
- finally {
- try {
- // try to close the reader.
- rd.close();
- }
- // Ignore the exception.
- catch (IOException exc) {}
- }
-
- if (factoryClassName != null &&
- ! "".equals(factoryClassName)) {
- if (DEBUG) debugPrintln("found in resource, value="
- + factoryClassName);
-
- // Note: here we do not want to fall back to the current
- // ClassLoader because we want to avoid the case where the
- // resource file was found using one ClassLoader and the
- // provider class was instantiated using a different one.
- return factoryClassName;
- }
-
- // No provider found
- return null;
- }
-
} // class ObjectFactory
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Transform.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Transform.java Thu Jun 06 20:47:13 2013 +0200
@@ -23,34 +23,30 @@
package com.sun.org.apache.xalan.internal.xsltc.cmdline;
-import java.io.FileNotFoundException;
-import java.net.MalformedURLException;
-import java.net.UnknownHostException;
-import java.util.Vector;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.sax.SAXSource;
-
+import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
+import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
+import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
+import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter;
import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
import com.sun.org.apache.xalan.internal.xsltc.runtime.Constants;
import com.sun.org.apache.xalan.internal.xsltc.runtime.Parameter;
import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
+import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
-
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.net.UnknownHostException;
+import java.util.Vector;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.sax.SAXSource;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
-import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
-import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
-import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-
/**
* @author Jacek Ambroziak
* @author Santiago Pericas-Geertsen
@@ -115,8 +111,7 @@
// Set the DOM's DOM builder as the XMLReader's SAX2 content handler
XSLTCDTMManager dtmManager =
- (XSLTCDTMManager)XSLTCDTMManager.getDTMManagerClass()
- .newInstance();
+ XSLTCDTMManager.createNewDTMManagerInstance();
DTMWSFilter wsfilter;
if (translet != null && translet instanceof StripFilter) {
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java Thu Jun 06 20:47:13 2013 +0200
@@ -156,8 +156,7 @@
public DocumentCache(int size) throws SAXException {
this(size, null);
try {
- _dtmManager = (XSLTCDTMManager)XSLTCDTMManager.getDTMManagerClass()
- .newInstance();
+ _dtmManager = XSLTCDTMManager.createNewDTMManagerInstance();
} catch (Exception e) {
throw new SAXException(e);
}
@@ -255,6 +254,7 @@
* Returns a document either by finding it in the cache or
* downloading it and putting it in the cache.
*/
+ @Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
CachedDocument doc;
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/XSLTCDTMManager.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/XSLTCDTMManager.java Thu Jun 06 20:47:13 2013 +0200
@@ -30,7 +30,6 @@
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stax.StAXSource;
-
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
import com.sun.org.apache.xml.internal.dtm.DTMException;
@@ -42,7 +41,6 @@
import com.sun.org.apache.xalan.internal.xsltc.trax.DOM2SAX;
import com.sun.org.apache.xalan.internal.xsltc.trax.StAXEvent2SAX;
import com.sun.org.apache.xalan.internal.xsltc.trax.StAXStream2SAX;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXNotRecognizedException;
@@ -55,13 +53,6 @@
public class XSLTCDTMManager extends DTMManagerDefault
{
- /** The default class name to use as the manager. */
- private static final String DEFAULT_CLASS_NAME =
- "com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager";
-
- private static final String DEFAULT_PROP_NAME =
- "com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager";
-
/** Set this to true if you want a dump of the DTM after creation */
private static final boolean DUMPTREE = false;
@@ -88,42 +79,13 @@
}
/**
- * Look up the class that provides the XSLTC DTM Manager service.
- * The following lookup procedure is used to find the service provider.
- * <ol>
- * <li>The value of the
- * <code>com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager</code> property, is
- * checked.</li>
- * <li>The <code>xalan.propeties</code> file is checked for a property
- * of the same name.</li>
- * <li>The
- * <code>META-INF/services/com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager</code>
- * file is checked.
- * </ol>
- * The default is <code>com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager</code>.
+ * Creates a new instance of the XSLTC DTM Manager service.
+ * Creates a new instance of the default class
+ * <code>com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager</code>.
*/
- public static Class getDTMManagerClass() {
- return getDTMManagerClass(true);
- }
-
- public static Class getDTMManagerClass(boolean useServicesMechanism) {
- Class mgrClass = null;
- if (useServicesMechanism) {
- mgrClass = ObjectFactory.lookUpFactoryClass(DEFAULT_PROP_NAME,
- null,
- DEFAULT_CLASS_NAME);
- } else {
- try {
- mgrClass = ObjectFactory.findProviderClass(DEFAULT_CLASS_NAME, true);
- } catch (Exception e) {
- //will not happen
- }
- }
- // If no class found, default to this one. (This should never happen -
- // the ObjectFactory has already been told that the current class is
- // the default).
- return (mgrClass != null) ? mgrClass : XSLTCDTMManager.class;
- }
+ public static XSLTCDTMManager createNewDTMManagerInstance() {
+ return newInstance();
+ }
/**
* Get an instance of a DTM, loaded with the content from the
@@ -146,6 +108,7 @@
*
* @return a non-null DTM reference.
*/
+ @Override
public DTM getDTM(Source source, boolean unique,
DTMWSFilter whiteSpaceFilter, boolean incremental,
boolean doIndexing)
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Thu Jun 06 20:47:13 2013 +0200
@@ -23,6 +23,17 @@
package com.sun.org.apache.xalan.internal.xsltc.trax;
+import com.sun.org.apache.xalan.internal.XalanConstants;
+import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
+import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
+import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
+import com.sun.org.apache.xml.internal.utils.StopParseException;
+import com.sun.org.apache.xml.internal.utils.StylesheetPIHandler;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -37,11 +48,9 @@
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import javax.xml.XMLConstants;
+import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Source;
@@ -58,23 +67,9 @@
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TemplatesHandler;
import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stax.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stax.*;
-
-import com.sun.org.apache.xml.internal.utils.StylesheetPIHandler;
-import com.sun.org.apache.xml.internal.utils.StopParseException;
-
-import com.sun.org.apache.xalan.internal.XalanConstants;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
-
import org.xml.sax.InputSource;
import org.xml.sax.XMLFilter;
import org.xml.sax.XMLReader;
@@ -201,14 +196,6 @@
private int _indentNumber = -1;
/**
- * The provider of the XSLTC DTM Manager service. This is fixed for any
- * instance of this class. In order to change service providers, a new
- * XSLTC <code>TransformerFactory</code> must be instantiated.
- * @see XSLTCDTMManager#getDTMManagerClass()
- */
- private Class m_DTMManagerClass;
-
- /**
* <p>State of secure processing feature.</p>
*/
private boolean _isNotSecureProcessing = true;
@@ -246,7 +233,6 @@
}
private TransformerFactoryImpl(boolean useServicesMechanism) {
- this.m_DTMManagerClass = XSLTCDTMManager.getDTMManagerClass(useServicesMechanism);
this._useServicesMechanism = useServicesMechanism;
String defaultAccess = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
@@ -269,6 +255,7 @@
* @param listener The error listener to use with the TransformerFactory
* @throws IllegalArgumentException
*/
+ @Override
public void setErrorListener(ErrorListener listener)
throws IllegalArgumentException
{
@@ -286,6 +273,7 @@
*
* @return The error listener used with the TransformerFactory
*/
+ @Override
public ErrorListener getErrorListener() {
return _errorListener;
}
@@ -298,6 +286,7 @@
* @return An object representing the attribute value
* @throws IllegalArgumentException
*/
+ @Override
public Object getAttribute(String name)
throws IllegalArgumentException
{
@@ -337,6 +326,7 @@
* @param value An object representing the attribute value
* @throws IllegalArgumentException
*/
+ @Override
public void setAttribute(String name, Object value)
throws IllegalArgumentException
{
@@ -459,6 +449,7 @@
* or the <code>Transformer</code>s or <code>Template</code>s it creates cannot support this feature.
* @throws NullPointerException If the <code>name</code> parameter is null.
*/
+ @Override
public void setFeature(String name, boolean value)
throws TransformerConfigurationException {
@@ -503,6 +494,7 @@
* @param name The feature name
* @return 'true' if feature is supported, 'false' if not
*/
+ @Override
public boolean getFeature(String name) {
// All supported features should be listed here
String[] features = {
@@ -554,6 +546,7 @@
* @return The URLResolver used for this TransformerFactory and all
* Templates and Transformer objects created using this factory
*/
+ @Override
public URIResolver getURIResolver() {
return _uriResolver;
}
@@ -568,6 +561,7 @@
* @param resolver The URLResolver used for this TransformerFactory and all
* Templates and Transformer objects created using this factory
*/
+ @Override
public void setURIResolver(URIResolver resolver) {
_uriResolver = resolver;
}
@@ -587,13 +581,14 @@
* @return A Source object suitable for passing to the TransformerFactory.
* @throws TransformerConfigurationException
*/
+ @Override
public Source getAssociatedStylesheet(Source source, String media,
String title, String charset)
throws TransformerConfigurationException {
String baseId;
- XMLReader reader = null;
- InputSource isource = null;
+ XMLReader reader;
+ InputSource isource;
/**
@@ -675,6 +670,7 @@
* @return A Transformer object that simply copies the source to the result.
* @throws TransformerConfigurationException
*/
+ @Override
public Transformer newTransformer()
throws TransformerConfigurationException
{
@@ -700,6 +696,7 @@
* @return A Templates object that can be used to create Transformers.
* @throws TransformerConfigurationException
*/
+ @Override
public Transformer newTransformer(Source source) throws
TransformerConfigurationException
{
@@ -763,6 +760,7 @@
* @return A Templates object that can be used to create Transformers.
* @throws TransformerConfigurationException
*/
+ @Override
public Templates newTemplates(Source source)
throws TransformerConfigurationException
{
@@ -796,7 +794,7 @@
// If _autoTranslet is true, we will try to load the bytecodes
// from the translet classes without compiling the stylesheet.
if (_autoTranslet) {
- byte[][] bytecodes = null;
+ byte[][] bytecodes;
String transletClassName = getTransletBaseName(source);
if (_packageName != null)
@@ -918,7 +916,7 @@
// Check that the transformation went well before returning
if (bytecodes == null) {
Vector errs = xsltc.getErrors();
- ErrorMsg err = null;
+ ErrorMsg err;
if (errs != null) {
err = (ErrorMsg)errs.elementAt(errs.size()-1);
} else {
@@ -963,6 +961,7 @@
* @return A TemplatesHandler object that can handle SAX events
* @throws TransformerConfigurationException
*/
+ @Override
public TemplatesHandler newTemplatesHandler()
throws TransformerConfigurationException
{
@@ -982,6 +981,7 @@
* @return A TransformerHandler object that can handle SAX events
* @throws TransformerConfigurationException
*/
+ @Override
public TransformerHandler newTransformerHandler()
throws TransformerConfigurationException
{
@@ -1002,6 +1002,7 @@
* @return A TransformerHandler object that can handle SAX events
* @throws TransformerConfigurationException
*/
+ @Override
public TransformerHandler newTransformerHandler(Source src)
throws TransformerConfigurationException
{
@@ -1022,6 +1023,7 @@
* @return A TransformerHandler object that can handle SAX events
* @throws TransformerConfigurationException
*/
+ @Override
public TransformerHandler newTransformerHandler(Templates templates)
throws TransformerConfigurationException
{
@@ -1039,6 +1041,7 @@
* @return An XMLFilter object, or null if this feature is not supported.
* @throws TransformerConfigurationException
*/
+ @Override
public XMLFilter newXMLFilter(Source src)
throws TransformerConfigurationException
{
@@ -1056,6 +1059,7 @@
* @return An XMLFilter object, or null if this feature is not supported.
* @throws TransformerConfigurationException
*/
+ @Override
public XMLFilter newXMLFilter(Templates templates)
throws TransformerConfigurationException
{
@@ -1087,6 +1091,7 @@
* @throws TransformerException if the application chooses to discontinue
* the transformation (always does in our case).
*/
+ @Override
public void error(TransformerException e)
throws TransformerException
{
@@ -1115,6 +1120,7 @@
* @throws TransformerException if the application chooses to discontinue
* the transformation (always does in our case).
*/
+ @Override
public void fatalError(TransformerException e)
throws TransformerException
{
@@ -1143,6 +1149,7 @@
* @throws TransformerException if the application chooses to discontinue
* the transformation (never does in our case).
*/
+ @Override
public void warning(TransformerException e)
throws TransformerException
{
@@ -1166,6 +1173,7 @@
* @param xsltc The compiler that resuests the document
* @return An InputSource with the loaded document
*/
+ @Override
public InputSource loadSource(String href, String context, XSLTC xsltc) {
try {
if (_uriResolver != null) {
@@ -1252,7 +1260,7 @@
Vector bytecodes = new Vector();
int fileLength = (int)transletFile.length();
if (fileLength > 0) {
- FileInputStream input = null;
+ FileInputStream input;
try {
input = new FileInputStream(transletFile);
}
@@ -1284,6 +1292,7 @@
// Find all the auxiliary files which have a name pattern of "transletClass$nnn.class".
final String transletAuxPrefix = transletName + "$";
File[] auxfiles = transletParentFile.listFiles(new FilenameFilter() {
+ @Override
public boolean accept(File dir, String name)
{
return (name.endsWith(".class") && name.startsWith(transletAuxPrefix));
@@ -1347,7 +1356,7 @@
xslFile = new File(xslFileName);
// Construct the path for the jar file
- String jarPath = null;
+ String jarPath;
if (_destinationDirectory != null)
jarPath = _destinationDirectory + "/" + _jarFileName;
else {
@@ -1372,7 +1381,7 @@
}
// Create a ZipFile object for the jar file
- ZipFile jarFile = null;
+ ZipFile jarFile;
try {
jarFile = new ZipFile(file);
}
@@ -1490,7 +1499,7 @@
if (file.exists())
return systemId;
else {
- URL url = null;
+ URL url;
try {
url = new URL(systemId);
}
@@ -1509,9 +1518,9 @@
}
/**
- * Returns the Class object the provides the XSLTC DTM Manager service.
+ * Returns a new instance of the XSLTC DTM Manager service.
*/
- protected Class getDTMManagerClass() {
- return m_DTMManagerClass;
+ protected final XSLTCDTMManager createNewDTMManagerInstance() {
+ return XSLTCDTMManager.createNewDTMManagerInstance();
}
}
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerHandlerImpl.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerHandlerImpl.java Thu Jun 06 20:47:13 2013 +0200
@@ -96,6 +96,7 @@
* resolved.
* @return The systemID that was set with setSystemId(String id)
*/
+ @Override
public String getSystemId() {
return _systemId;
}
@@ -106,6 +107,7 @@
* resolved.
* @param id Base URI for this stylesheet
*/
+ @Override
public void setSystemId(String id) {
_systemId = id;
}
@@ -116,6 +118,7 @@
* order to set parameters and output properties.
* @return The Transformer object
*/
+ @Override
public Transformer getTransformer() {
return _transformer;
}
@@ -127,6 +130,7 @@
* @param result A Result instance, should not be null
* @throws IllegalArgumentException if result is invalid for some reason
*/
+ @Override
public void setResult(Result result) throws IllegalArgumentException {
_result = result;
@@ -166,6 +170,7 @@
* Implements org.xml.sax.ContentHandler.characters()
* Receive notification of character data.
*/
+ @Override
public void characters(char[] ch, int start, int length)
throws SAXException
{
@@ -176,6 +181,7 @@
* Implements org.xml.sax.ContentHandler.startDocument()
* Receive notification of the beginning of a document.
*/
+ @Override
public void startDocument() throws SAXException {
// Make sure setResult() was called before the first SAX event
if (_result == null) {
@@ -189,10 +195,8 @@
// Create an internal DOM (not W3C) and get SAX2 input handler
try {
- dtmManager =
- (XSLTCDTMManager)_transformer.getTransformerFactory()
- .getDTMManagerClass()
- .newInstance();
+ dtmManager = _transformer.getTransformerFactory()
+ .createNewDTMManagerInstance();
} catch (Exception e) {
throw new SAXException(e);
}
@@ -230,6 +234,7 @@
* Implements org.xml.sax.ContentHandler.endDocument()
* Receive notification of the end of a document.
*/
+ @Override
public void endDocument() throws SAXException {
// Signal to the DOMBuilder that the document is complete
_handler.endDocument();
@@ -260,6 +265,7 @@
* Implements org.xml.sax.ContentHandler.startElement()
* Receive notification of the beginning of an element.
*/
+ @Override
public void startElement(String uri, String localName,
String qname, Attributes attributes)
throws SAXException
@@ -271,6 +277,7 @@
* Implements org.xml.sax.ContentHandler.endElement()
* Receive notification of the end of an element.
*/
+ @Override
public void endElement(String namespaceURI, String localName, String qname)
throws SAXException
{
@@ -281,6 +288,7 @@
* Implements org.xml.sax.ContentHandler.processingInstruction()
* Receive notification of a processing instruction.
*/
+ @Override
public void processingInstruction(String target, String data)
throws SAXException
{
@@ -290,6 +298,7 @@
/**
* Implements org.xml.sax.ext.LexicalHandler.startCDATA()
*/
+ @Override
public void startCDATA() throws SAXException {
if (_lexHandler != null) {
_lexHandler.startCDATA();
@@ -299,6 +308,7 @@
/**
* Implements org.xml.sax.ext.LexicalHandler.endCDATA()
*/
+ @Override
public void endCDATA() throws SAXException {
if (_lexHandler != null) {
_lexHandler.endCDATA();
@@ -309,6 +319,7 @@
* Implements org.xml.sax.ext.LexicalHandler.comment()
* Receieve notification of a comment
*/
+ @Override
public void comment(char[] ch, int start, int length)
throws SAXException
{
@@ -322,6 +333,7 @@
* Receive notification of ignorable whitespace in element
* content. Similar to characters(char[], int, int).
*/
+ @Override
public void ignorableWhitespace(char[] ch, int start, int length)
throws SAXException
{
@@ -332,6 +344,7 @@
* Implements org.xml.sax.ContentHandler.setDocumentLocator()
* Receive an object for locating the origin of SAX document events.
*/
+ @Override
public void setDocumentLocator(Locator locator) {
_locator = locator;
@@ -344,6 +357,7 @@
* Implements org.xml.sax.ContentHandler.skippedEntity()
* Receive notification of a skipped entity.
*/
+ @Override
public void skippedEntity(String name) throws SAXException {
_handler.skippedEntity(name);
}
@@ -352,6 +366,7 @@
* Implements org.xml.sax.ContentHandler.startPrefixMapping()
* Begin the scope of a prefix-URI Namespace mapping.
*/
+ @Override
public void startPrefixMapping(String prefix, String uri)
throws SAXException {
_handler.startPrefixMapping(prefix, uri);
@@ -361,6 +376,7 @@
* Implements org.xml.sax.ContentHandler.endPrefixMapping()
* End the scope of a prefix-URI Namespace mapping.
*/
+ @Override
public void endPrefixMapping(String prefix) throws SAXException {
_handler.endPrefixMapping(prefix);
}
@@ -368,6 +384,7 @@
/**
* Implements org.xml.sax.ext.LexicalHandler.startDTD()
*/
+ @Override
public void startDTD(String name, String publicId, String systemId)
throws SAXException
{
@@ -379,6 +396,7 @@
/**
* Implements org.xml.sax.ext.LexicalHandler.endDTD()
*/
+ @Override
public void endDTD() throws SAXException {
if (_lexHandler != null) {
_lexHandler.endDTD();
@@ -388,6 +406,7 @@
/**
* Implements org.xml.sax.ext.LexicalHandler.startEntity()
*/
+ @Override
public void startEntity(String name) throws SAXException {
if (_lexHandler != null) {
_lexHandler.startEntity(name);
@@ -397,6 +416,7 @@
/**
* Implements org.xml.sax.ext.LexicalHandler.endEntity()
*/
+ @Override
public void endEntity(String name) throws SAXException {
if (_lexHandler != null) {
_lexHandler.endEntity(name);
@@ -406,6 +426,7 @@
/**
* Implements org.xml.sax.DTDHandler.unparsedEntityDecl()
*/
+ @Override
public void unparsedEntityDecl(String name, String publicId,
String systemId, String notationName) throws SAXException
{
@@ -418,6 +439,7 @@
/**
* Implements org.xml.sax.DTDHandler.notationDecl()
*/
+ @Override
public void notationDecl(String name, String publicId, String systemId)
throws SAXException
{
@@ -429,6 +451,7 @@
/**
* Implements org.xml.sax.ext.DeclHandler.attributeDecl()
*/
+ @Override
public void attributeDecl(String eName, String aName, String type,
String valueDefault, String value) throws SAXException
{
@@ -440,6 +463,7 @@
/**
* Implements org.xml.sax.ext.DeclHandler.elementDecl()
*/
+ @Override
public void elementDecl(String name, String model)
throws SAXException
{
@@ -451,6 +475,7 @@
/**
* Implements org.xml.sax.ext.DeclHandler.externalEntityDecl()
*/
+ @Override
public void externalEntityDecl(String name, String publicId, String systemId)
throws SAXException
{
@@ -462,6 +487,7 @@
/**
* Implements org.xml.sax.ext.DeclHandler.externalEntityDecl()
*/
+ @Override
public void internalEntityDecl(String name, String value)
throws SAXException
{
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Thu Jun 06 20:47:13 2013 +0200
@@ -99,10 +99,6 @@
public final class TransformerImpl extends Transformer
implements DOMCache, ErrorListener
{
- private final static String EMPTY_STRING = "";
- private final static String NO_STRING = "no";
- private final static String YES_STRING = "yes";
- private final static String XML_STRING = "xml";
private final static String LEXICAL_HANDLER_PROPERTY =
"http://xml.org/sax/properties/lexical-handler";
@@ -156,7 +152,7 @@
private TransletOutputHandlerFactory _tohFactory = null;
/**
- * A reference to a internal DOM represenation of the input.
+ * A reference to a internal DOM representation of the input.
*/
private DOM _dom = null;
@@ -238,6 +234,7 @@
_errorListener = errorListener;
}
+ @Override
public void displayMessage(String msg) {
if(_errorListener == null) {
System.err.println(msg);
@@ -323,6 +320,7 @@
* @param result Will contain the output from the transformation
* @throws TransformerException
*/
+ @Override
public void transform(Source source, Result result)
throws TransformerException
{
@@ -465,7 +463,7 @@
// System Id may be in one of several forms, (1) a uri
// that starts with 'file:', (2) uri that starts with 'http:'
// or (3) just a filename on the local system.
- URL url = null;
+ URL url;
if (systemId.startsWith("file:")) {
// if StreamResult(File) or setSystemID(File) was used,
// the systemId will be URI encoded as a result of File.toURI(),
@@ -537,7 +535,7 @@
*/
private DOM getDOM(Source source) throws TransformerException {
try {
- DOM dom = null;
+ DOM dom;
if (source != null) {
DTMWSFilter wsfilter;
@@ -552,8 +550,7 @@
if (_dtmManager == null) {
_dtmManager =
- (XSLTCDTMManager)_tfactory.getDTMManagerClass()
- .newInstance();
+ _tfactory.createNewDTMManagerInstance();
_dtmManager.setServicesMechnism(_useServicesMechanism);
}
dom = (DOM)_dtmManager.getDTM(source, false, wsfilter, true,
@@ -676,8 +673,8 @@
}
} else if (source instanceof StAXSource) {
final StAXSource staxSource = (StAXSource)source;
- StAXEvent2SAX staxevent2sax = null;
- StAXStream2SAX staxStream2SAX = null;
+ StAXEvent2SAX staxevent2sax;
+ StAXStream2SAX staxStream2SAX;
if (staxSource.getXMLEventReader() != null) {
final XMLEventReader xmlEventReader = staxSource.getXMLEventReader();
staxevent2sax = new StAXEvent2SAX(xmlEventReader);
@@ -770,6 +767,7 @@
*
* @return The error event handler currently in effect
*/
+ @Override
public ErrorListener getErrorListener() {
return _errorListener;
}
@@ -783,6 +781,7 @@
* @param listener The error event listener to use
* @throws IllegalArgumentException
*/
+ @Override
public void setErrorListener(ErrorListener listener)
throws IllegalArgumentException {
if (listener == null) {
@@ -830,7 +829,7 @@
// Return a 'null' string if no CDATA section elements were specified
if (cdata == null) return null;
- StringBuffer result = new StringBuffer();
+ final StringBuilder result = new StringBuilder();
// Get an enumeration of all the elements in the hashtable
Enumeration elements = cdata.keys();
@@ -857,6 +856,7 @@
*
* @return Properties in effect for this Transformer
*/
+ @Override
public Properties getOutputProperties() {
return (Properties) _properties.clone();
}
@@ -870,6 +870,7 @@
* @param name A non-null string that contains the name of the property
* @throws IllegalArgumentException if the property name is not known
*/
+ @Override
public String getOutputProperty(String name)
throws IllegalArgumentException
{
@@ -889,6 +890,7 @@
* @param properties The properties to use for the Transformer
* @throws IllegalArgumentException Never, errors are ignored
*/
+ @Override
public void setOutputProperties(Properties properties)
throws IllegalArgumentException
{
@@ -925,6 +927,7 @@
* @param value The value to assign to the property
* @throws IllegalArgumentException Never, errors are ignored
*/
+ @Override
public void setOutputProperty(String name, String value)
throws IllegalArgumentException
{
@@ -1205,6 +1208,7 @@
* @param name The name of the parameter
* @param value The value to assign to the parameter
*/
+ @Override
public void setParameter(String name, Object value) {
if (value == null) {
@@ -1228,6 +1232,7 @@
* Clear all parameters set with setParameter. Clears the translet's
* parameter stack.
*/
+ @Override
public void clearParameters() {
if (_isIdentity && _parameters != null) {
_parameters.clear();
@@ -1245,6 +1250,7 @@
* @param name The name of the parameter
* @return An object that contains the value assigned to the parameter
*/
+ @Override
public final Object getParameter(String name) {
if (_isIdentity) {
return (_parameters != null) ? _parameters.get(name) : null;
@@ -1260,6 +1266,7 @@
*
* @return The URLResolver object currently in use
*/
+ @Override
public URIResolver getURIResolver() {
return _uriResolver;
}
@@ -1270,6 +1277,7 @@
*
* @param resolver The URIResolver to use in document()
*/
+ @Override
public void setURIResolver(URIResolver resolver) {
_uriResolver = resolver;
}
@@ -1288,6 +1296,7 @@
* @param href The href argument passed to the document function.
* @param translet A reference to the translet requesting the document
*/
+ @Override
public DOM retrieveDocument(String baseURI, String href, Translet translet) {
try {
// Argument to document function was: document('');
@@ -1330,6 +1339,7 @@
* @throws TransformerException if the application chooses to discontinue
* the transformation (always does in our case).
*/
+ @Override
public void error(TransformerException e)
throws TransformerException
{
@@ -1358,6 +1368,7 @@
* @throws TransformerException if the application chooses to discontinue
* the transformation (always does in our case).
*/
+ @Override
public void fatalError(TransformerException e)
throws TransformerException
{
@@ -1386,6 +1397,7 @@
* @throws TransformerException if the application chooses to discontinue
* the transformation (never does in our case).
*/
+ @Override
public void warning(TransformerException e)
throws TransformerException
{
@@ -1406,6 +1418,7 @@
* created
* @since 1.5
*/
+ @Override
public void reset() {
_method = null;
--- a/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java Thu Jun 06 20:47:13 2013 +0200
@@ -20,15 +20,6 @@
package com.sun.org.apache.xerces.internal.utils;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-
-import java.util.Properties;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
/**
* This class is duplicated for each JAXP subpackage so keep it in sync.
* It is package private and therefore is not exposed as part of the JAXP
@@ -50,113 +41,9 @@
//
private static final String DEFAULT_INTERNAL_CLASSES = "com.sun.org.apache.";
- // name of default properties file to look for in JDK's jre/lib directory
- private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties";
-
/** Set to true for debugging */
private static final boolean DEBUG = isDebugEnabled();
- /**
- * Default columns per line.
- */
- private static final int DEFAULT_LINE_LENGTH = 80;
-
- /** cache the contents of the xerces.properties file.
- * Until an attempt has been made to read this file, this will
- * be null; if the file does not exist or we encounter some other error
- * during the read, this will be empty.
- */
- private static Properties fXercesProperties = null;
-
- /***
- * Cache the time stamp of the xerces.properties file so
- * that we know if it's been modified and can invalidate
- * the cache when necessary.
- */
- private static long fLastModified = -1;
-
- //
- // static methods
- //
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return Class object of factory, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- public static Object createObject(String factoryId, String fallbackClassName)
- throws ConfigurationError {
- return createObject(factoryId, null, fallbackClassName);
- } // createObject(String,String):Object
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return Class object of factory, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param propertiesFilename The filename in the $java.home/lib directory
- * of the properties file. If none specified,
- * ${java.home}/lib/xerces.properties will be used.
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- public static Object createObject(String factoryId,
- String propertiesFilename,
- String fallbackClassName)
- throws ConfigurationError
- {
- if (DEBUG) debugPrintln("debug is on");
-
- ClassLoader cl = findClassLoader();
-
- // Use the system property first
- try {
- String systemProp = SecuritySupport.getSystemProperty(factoryId);
- if (systemProp != null && systemProp.length() > 0) {
- if (DEBUG) debugPrintln("found system property, value=" + systemProp);
- return newInstance(systemProp, cl, true);
- }
- } catch (SecurityException se) {
- // Ignore and continue w/ next location
- }
-
- // JAXP specific change
- // always use fallback class to avoid the expense of constantly
- // "stat"ing a non-existent "xerces.properties" and jar SPI entry
- // see CR 6400863: Expensive creating of SAX parser in Mustang
- if (fallbackClassName == null) {
- throw new ConfigurationError(
- "Provider for " + factoryId + " cannot be found", null);
- }
-
- if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName);
- return newInstance(fallbackClassName, cl, true);
-
- } // createObject(String,String,String):Object
//
// Private static methods
@@ -235,7 +122,7 @@
// Check for any extension ClassLoaders in chain up to
// boot ClassLoader
chain = SecuritySupport.getParentClassLoader(chain);
- };
+ }
// Assert: Context ClassLoader not in chain of
// boot/extension/system ClassLoaders
@@ -343,94 +230,4 @@
return providerClass;
}
- /*
- * Try to find provider using Jar Service Provider Mechanism
- *
- * @return instance of provider class if found or null
- */
- private static Object findJarServiceProvider(String factoryId)
- throws ConfigurationError
- {
- String serviceId = "META-INF/services/" + factoryId;
- InputStream is = null;
-
- // First try the Context ClassLoader
- ClassLoader cl = findClassLoader();
-
- is = SecuritySupport.getResourceAsStream(cl, serviceId);
-
- // If no provider found then try the current ClassLoader
- if (is == null) {
- ClassLoader current = ObjectFactory.class.getClassLoader();
- if (cl != current) {
- cl = current;
- is = SecuritySupport.getResourceAsStream(cl, serviceId);
- }
- }
-
- if (is == null) {
- // No provider found
- return null;
- }
-
- if (DEBUG) debugPrintln("found jar resource=" + serviceId +
- " using ClassLoader: " + cl);
-
- // Read the service provider name in UTF-8 as specified in
- // the jar spec. Unfortunately this fails in Microsoft
- // VJ++, which does not implement the UTF-8
- // encoding. Theoretically, we should simply let it fail in
- // that case, since the JVM is obviously broken if it
- // doesn't support such a basic standard. But since there
- // are still some users attempting to use VJ++ for
- // development, we have dropped in a fallback which makes a
- // second attempt using the platform's default encoding. In
- // VJ++ this is apparently ASCII, which is a subset of
- // UTF-8... and since the strings we'll be reading here are
- // also primarily limited to the 7-bit ASCII range (at
- // least, in English versions), this should work well
- // enough to keep us on the air until we're ready to
- // officially decommit from VJ++. [Edited comment from
- // jkesselm]
- BufferedReader rd;
- try {
- rd = new BufferedReader(new InputStreamReader(is, "UTF-8"), DEFAULT_LINE_LENGTH);
- } catch (java.io.UnsupportedEncodingException e) {
- rd = new BufferedReader(new InputStreamReader(is), DEFAULT_LINE_LENGTH);
- }
-
- String factoryClassName = null;
- try {
- // XXX Does not handle all possible input as specified by the
- // Jar Service Provider specification
- factoryClassName = rd.readLine();
- } catch (IOException x) {
- // No provider found
- return null;
- }
- finally {
- try {
- // try to close the reader.
- rd.close();
- }
- // Ignore the exception.
- catch (IOException exc) {}
- }
-
- if (factoryClassName != null &&
- ! "".equals(factoryClassName)) {
- if (DEBUG) debugPrintln("found in resource, value="
- + factoryClassName);
-
- // Note: here we do not want to fall back to the current
- // ClassLoader because we want to avoid the case where the
- // resource file was found using one ClassLoader and the
- // provider class was instantiated using a different one.
- return newInstance(factoryClassName, cl, false);
- }
-
- // No provider found
- return null;
- }
-
} // class ObjectFactory
--- a/jaxp/src/com/sun/org/apache/xml/internal/dtm/DTMManager.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xml/internal/dtm/DTMManager.java Thu Jun 06 20:47:13 2013 +0200
@@ -52,14 +52,6 @@
public abstract class DTMManager
{
- /** The default property name to load the manager. */
- private static final String defaultPropName =
- "com.sun.org.apache.xml.internal.dtm.DTMManager";
-
- /** The default class name to use as the manager. */
- private static String defaultClassName =
- "com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault";
-
/**
* Factory for creating XMLString objects.
* %TBD% Make this set by the caller.
@@ -97,29 +89,7 @@
/**
* Obtain a new instance of a <code>DTMManager</code>.
* This static method creates a new factory instance
- * This method uses the following ordered lookup procedure to determine
- * the <code>DTMManager</code> implementation class to
- * load:
- * <ul>
- * <li>
- * Use the <code>com.sun.org.apache.xml.internal.dtm.DTMManager</code> system
- * property.
- * </li>
- * <li>
- * Use the JAVA_HOME(the parent directory where jdk is
- * installed)/lib/xalan.properties for a property file that contains the
- * name of the implementation class keyed on the same value as the
- * system property defined above.
- * </li>
- * <li>
- * Use the Services API (as detailed in the JAR specification), if
- * available, to determine the classname. The Services API will look
- * for a classname in the file
- * <code>META-INF/services/com.sun.org.apache.xml.internal.dtm.DTMManager</code>
- * in jars available to the runtime.
- * </li>
- * <li>
- * Use the default <code>DTMManager</code> classname, which is
+ * using the default <code>DTMManager</code> implementation, which is
* <code>com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault</code>.
* </li>
* </ul>
@@ -136,39 +106,10 @@
public static DTMManager newInstance(XMLStringFactory xsf)
throws DTMConfigurationException
{
- return newInstance(xsf, true);
- }
+ final DTMManager factoryImpl = new com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault();
+ factoryImpl.setXMLStringFactory(xsf);
- public static DTMManager newInstance(XMLStringFactory xsf, boolean useServicesMechanism)
- throws DTMConfigurationException
- {
- DTMManager factoryImpl = null;
- try
- {
- if (useServicesMechanism) {
- factoryImpl = (DTMManager) ObjectFactory
- .createObject(defaultPropName, defaultClassName);
- } else {
- factoryImpl = new com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault();
- }
- }
- catch (ConfigurationError e)
- {
- throw new DTMConfigurationException(XMLMessages.createXMLMessage(
- XMLErrorResources.ER_NO_DEFAULT_IMPL, null), e.getException());
- //"No default implementation found");
- }
-
- if (factoryImpl == null)
- {
- throw new DTMConfigurationException(XMLMessages.createXMLMessage(
- XMLErrorResources.ER_NO_DEFAULT_IMPL, null));
- //"No default implementation found");
- }
-
- factoryImpl.setXMLStringFactory(xsf);
-
- return factoryImpl;
+ return factoryImpl;
}
/**
--- a/jaxp/src/com/sun/org/apache/xpath/internal/XPathContext.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xpath/internal/XPathContext.java Thu Jun 06 20:47:13 2013 +0200
@@ -22,17 +22,6 @@
*/
package com.sun.org.apache.xpath.internal;
-import java.lang.reflect.Method;
-import java.util.Stack;
-import java.util.Vector;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import javax.xml.transform.ErrorListener;
-import javax.xml.transform.SourceLocator;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.URIResolver;
-
import com.sun.org.apache.xalan.internal.extensions.ExpressionContext;
import com.sun.org.apache.xalan.internal.res.XSLMessages;
import com.sun.org.apache.xml.internal.dtm.Axis;
@@ -46,14 +35,21 @@
import com.sun.org.apache.xml.internal.utils.NodeVector;
import com.sun.org.apache.xml.internal.utils.ObjectStack;
import com.sun.org.apache.xml.internal.utils.PrefixResolver;
-import com.sun.org.apache.xml.internal.utils.SAXSourceLocator;
import com.sun.org.apache.xml.internal.utils.XMLString;
import com.sun.org.apache.xpath.internal.axes.SubContextList;
+import com.sun.org.apache.xpath.internal.objects.DTMXRTreeFrag;
import com.sun.org.apache.xpath.internal.objects.XObject;
-import com.sun.org.apache.xpath.internal.objects.DTMXRTreeFrag;
import com.sun.org.apache.xpath.internal.objects.XString;
import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
-
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Stack;
+import java.util.Vector;
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.SourceLocator;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
import org.xml.sax.XMLReader;
/**
@@ -339,8 +335,8 @@
m_saxLocations.push(null);
m_useServicesMechanism = useServicesMechanism;
m_dtmManager = DTMManager.newInstance(
- com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory(),
- m_useServicesMechanism);
+ com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory()
+ );
}
/**
@@ -363,8 +359,8 @@
m_dtmManager = DTMManager.newInstance(
- com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory(),
- m_useServicesMechanism);
+ com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory()
+ );
m_saxLocations.removeAllElements();
m_axesIteratorStack.removeAllElements();
@@ -622,32 +618,6 @@
/** Misnamed string manager for XPath messages. */
// private static XSLMessages m_XSLMessages = new XSLMessages();
- /**
- * Tell the user of an assertion error, and probably throw an
- * exception.
- *
- * @param b If false, a TransformerException will be thrown.
- * @param msg The assertion message, which should be informative.
- *
- * @throws javax.xml.transform.TransformerException if b is false.
- */
- private void assertion(boolean b, String msg) throws javax.xml.transform.TransformerException
- {
- if (!b)
- {
- ErrorListener errorHandler = getErrorListener();
-
- if (errorHandler != null)
- {
- errorHandler.fatalError(
- new TransformerException(
- XSLMessages.createMessage(
- XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION,
- new Object[]{ msg }), (SAXSourceLocator)this.getSAXLocator()));
- }
- }
- }
-
//==========================================================
// SECTION: Execution context state tracking
//==========================================================
@@ -664,7 +634,7 @@
* Get the current context node list.
*
* @return the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
- * also refered to here as a <term>context node list</term>.
+ * also referred to here as a <term>context node list</term>.
*/
public final DTMIterator getContextNodeList()
{
@@ -679,7 +649,7 @@
* Set the current context node list.
*
* @param nl the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
- * also refered to here as a <term>context node list</term>.
+ * also referred to here as a <term>context node list</term>.
* @xsl.usage internal
*/
public final void pushContextNodeList(DTMIterator nl)
@@ -700,7 +670,7 @@
}
/**
- * The ammount to use for stacks that record information during the
+ * The amount to use for stacks that record information during the
* recursive execution.
*/
public static final int RECURSIONLIMIT = (1024*4);