santiagopg 2002/09/25 13:45:54
Modified: java/src/org/apache/xalan/xsltc/trax
TransformerFactoryImpl.java
Log:
Use a thread variable to cache an XMLReader.
Revision Changes Path
1.48 +15 -3
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.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- TransformerFactoryImpl.java 23 Sep 2002 18:21:54 -0000 1.47
+++ TransformerFactoryImpl.java 25 Sep 2002 20:45:54 -0000 1.48
@@ -126,6 +126,12 @@
*/
private Hashtable _piParams = null;
+
+ /**
+ * Use a thread local variable to store a copy of an XML Reader.
+ */
+ static ThreadLocal _xmlReader = new ThreadLocal();
+
/**
* The above hashtable stores objects of this class.
*/
@@ -727,7 +733,8 @@
/**
* 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.
+ * 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
@@ -735,6 +742,11 @@
_parserFactory = SAXParserFactory.newInstance();
_parserFactory.setNamespaceAware(true);
}
- return _parserFactory.newSAXParser().getXMLReader();
+ XMLReader result = (XMLReader) _xmlReader.get();
+ if (result == null) {
+ _xmlReader.set(
+ result = _parserFactory.newSAXParser().getXMLReader());
+ }
+ return result;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]