Project

Profile

Help

is TransformerFactory threadsafe ?

Added by Anonymous over 14 years ago

Legacy ID: #8482406 Legacy Poster: ageissler (ageissler)

Hello, I use Saxon Transformer Transformerfactory.newInstance().newTransformer() for transforming DomSource to Writer. My Question is : Can I make the TransformerFactory static so that only one Factory creates Transformers for different threads ? Regards, Andre


Replies (1)

RE: is TransformerFactory threadsafe ? - Added by Anonymous over 14 years ago

Legacy ID: #8482720 Legacy Poster: Michael Kay (mhkay)

It should be perfectly safe to use a TransformerFactory concurrently in different threads, provided of course that you don't try setting its properties such as the ErrorListener and URIResolver. However, I'm not sure it's wise to make it static. Underneath the Saxon TransformerFactory is the Saxon Configuration, and this owns all kinds of resources like loaded schemas, the namepool, and so on. While it's fine to share these across threads in a single application, at some point you may want to run multiple applications concurrently within the same JVM, and you will want to have the flexibility to unload these resources when the application finishes, or to have different schemas and namepools in different applications.

    (1-1/1)

    Please register to reply