You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Tom Amiro <To...@Sun.COM> on 2002/09/26 16:07:52 UTC
Re: cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/trax
TransformerFactoryImpl.java
Boy this may be an important fix. Thanks Santiago!
santiagopg@apache.org wrote:
>
> 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: xalan-cvs-unsubscribe@xml.apache.org
> For additional commands, e-mail: xalan-cvs-help@xml.apache.org
--
Tom Amiro -- SQA Engineer
Sun XML Technology Development
voice: 781-442-0589 Fax: 781-442-1437
eMail: tom.amiro@.sun.com