Hi David,

     Transformer instances are not thread-safe, regardless of whether they 
are created by a TransformerFactory or from a Templates object.  From 
Section 3.4 of the JAXP 1.2 specification, "Implementations of the SAXParser, 
DocumentBuilder and Transformer abstract 
classes are not expected to be thread safe by this specification."

     Templates objects exist in order to create multiple Transformer 
instances, without the need to reprocess the source stylesheet each time. 
A Templates object is thread-safe, so any thread can create a Transformer 
object from a Templates object at any time, and can cache that 
thread-specific instance for reuse.

Thanks,

Henry
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
mailto:[EMAIL PROTECTED]




"Karr, David" <[EMAIL PROTECTED]>
2003-08-29 10:53 AM

 
        To:     [EMAIL PROTECTED]
        cc: 
        Subject:        Caching Templates object instead of Transformer object

 

In superficial examples of using Transformers, it appears that it's safe
to cache Transformer objects for reuse.  However, in recent reading,
I've seen references to using the Templates object instead (isn't that
an odd class name?).  Apparently the Transformer instances created
directly by the TransformerFactory are not thread-safe, but the
Transformer instances created by the Templates object are.  Is this
correct?  How is this thread-safety ensured?  I would have guessed that
there would be different subclasses of "Transformer" being used, but I
don't see that happening.



Reply via email to