You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2003/12/04 17:44:56 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/trax TransformerFactoryImpl.java
zongaro 2003/12/04 08:44:56
Modified: java/src/org/apache/xalan/xsltc/trax
TransformerFactoryImpl.java
Log:
Changes to permit different DTM implementations to be supplied to XSLTC.
XSLTC will now use ObjectFactory to look up a new XSLTC DTM Manager service
provider (org.apache.xalan.xsltc.dom.XSLTCDTMManager). The provider is looked
up once when a TransformerFactory is created, and used by any Transformer
objects created by that TransformerFactory.
Also, moved code for caching XMLReader objects from XSLTC's
TransformerFactoryImpl to a new org.apache.xml.utils.XMLReaderManager class.
It is now the responsibility of the DTMManagerDefault class to request one of
these cached XMLReader objects, so the benefit of reusing an XMLReader is now
conferred upon both XSLTC and Xalan-J Interpretive, as well as upon references
to the document() function.
Revision Changes Path
1.70 +15 -49 xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
Index: TransformerFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- TransformerFactoryImpl.java 21 Nov 2003 18:34:41 -0000 1.69
+++ TransformerFactoryImpl.java 4 Dec 2003 16:44:56 -0000 1.70
@@ -106,6 +106,7 @@
import org.apache.xalan.xsltc.compiler.SourceLoader;
import org.apache.xalan.xsltc.compiler.XSLTC;
import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
+import org.apache.xalan.xsltc.dom.XSLTCDTMManager;
import org.apache.xml.utils.ObjectFactory;
@@ -238,15 +239,18 @@
private int _indentNumber = -1;
/**
- * A reference to a SAXParserFactory.
+ * 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 SAXParserFactory _parserFactory = null;
+ private Class m_DTMManagerClass;
/**
* javax.xml.transform.sax.TransformerFactory implementation.
- * Contains nothing yet
*/
public TransformerFactoryImpl() {
+ m_DTMManagerClass = XSLTCDTMManager.getDTMManagerClass();
}
/**
@@ -1041,51 +1045,6 @@
}
/**
- * This method is synchronized to allow instances of this class to
- * be shared among threads. A tranformer object will call this
- * method to get an XMLReader. A different instance of an XMLReader
- * is returned/cached for each thread.
- */
- public synchronized XMLReader getXMLReader() throws Exception {
- // First check if factory is instantiated
- if (_parserFactory == null) {
- _parserFactory = SAXParserFactory.newInstance();
- _parserFactory.setNamespaceAware(true);
- }
- XMLReader result = (XMLReader) _xmlReader.get();
- if (result == null) {
- try {
- /*
- * Fix for bug 24695
- * According to JAXP 1.2 specification if a SAXSource
- * is created using a SAX InputSource the Transformer or
- * TransformerFactory creates a reader via the XMLReaderFactory
- * if setXMLReader is not used
- */
- result = XMLReaderFactory.createXMLReader();
- }
- catch (Exception e) {
- try {
- // If unable to create an instance, let's try to use
- // the XMLReader from JAXP
- result = _parserFactory.newSAXParser().getXMLReader();
- }
- catch (ParserConfigurationException pce) {
- throw e; // ignore pce
- }
- }
-
- result.setFeature("http://xml.org/sax/features/namespaces",
- true);
- result.setFeature("http://xml.org/sax/features/namespace-prefixes",
- false);
- _xmlReader.set(result);
-
- }
- return result;
- }
-
- /**
* Reset the per-session attributes to their default values
*/
private void resetTransientAttributes() {
@@ -1407,5 +1366,12 @@
}
else
return null;
+ }
+
+ /**
+ * Returns the Class object the provides the XSLTC DTM Manager service.
+ */
+ protected Class getDTMManagerClass() {
+ return m_DTMManagerClass;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org