org.ibisph.xslt
Class TemplateCachingTransformerFactory

java.lang.Object
  extended by org.ibisph.xslt.TransformerFactory
      extended by org.ibisph.xslt.TemplateCachingTransformerFactory

public class TemplateCachingTransformerFactory
extends TransformerFactory

Provides caching parsed XSLTs and dealing with non thread safe transformers. If an XSLT is updated or new, non cached transformer then the specified XSLT is read and then ran through the transformer parser. Finally, the parsed transformer is saved in a hash with the XSLT filename acting as the key to the transformer.

NOTE: XSLTc could be used to improve performance and resource utilization. However, since most users of the IBISPH-IRV system should use the artifact mechanism, implementing XSLTc was not pursued.

Author:
Garth Braithwaite, STG

Field Summary
 
Fields inherited from class org.ibisph.xslt.TransformerFactory
transformerFactory
 
Constructor Summary
TemplateCachingTransformerFactory(java.lang.String transformerFactoryClassName)
          Factory constructor which allows a for a different non default JAXP TransformerFactory to be used.
 
Method Summary
static void clear()
          Clears all cached XSLT Transformers.
static void clear(java.lang.String xsltFilename)
          Clears specified cached XSLT Transformer.
static javax.xml.transform.Transformer newTransformer(java.lang.String xsltURISystemID)
          Main factory method used to get/create a managed XSLT template.
static void setTransformerFactoryClassName(java.lang.String transformerFactoryClassName)
          Sets specified XSLT Transformation Engine.
 
Methods inherited from class org.ibisph.xslt.TransformerFactory
newTransformer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateCachingTransformerFactory

public TemplateCachingTransformerFactory(java.lang.String transformerFactoryClassName)
Factory constructor which allows a for a different non default JAXP TransformerFactory to be used. Simply calls super(string);

Parameters:
transformerFactoryClassName - Fully qualified class name of the transformation factory to use.
Method Detail

setTransformerFactoryClassName

public static void setTransformerFactoryClassName(java.lang.String transformerFactoryClassName)
Sets specified XSLT Transformation Engine. This allows for Saxon or any other XSLT engine to be used in an environment that already has an endorsed JVM or Application Server XSLT engine (typically Xalan). This can also be accomplished via setting a system property or changing the jars inside the JVM or App Server's endorsed directory. The down side to the latter is that ALL applications will then be forced to use that XSLT engine.

Parameters:
transformerFactoryClassName - Fully qualified class name of the transformation factory to use.

clear

public static void clear()
Clears all cached XSLT Transformers.


clear

public static void clear(java.lang.String xsltFilename)
Clears specified cached XSLT Transformer.

Parameters:
xsltFilename - Removes the specified XSLT filename from the cache.

newTransformer

public static javax.xml.transform.Transformer newTransformer(java.lang.String xsltURISystemID)
                                                      throws javax.xml.transform.TransformerConfigurationException,
                                                             java.io.FileNotFoundException
Main factory method used to get/create a managed XSLT template. Templates are parsed, thread safe objects that can return a single use transformer. The xsltURISystemID parameter is used as a key to a map cache that returns the template. If the XSLT is found in the cache then a new Transformer instance for the specified XSLT file is created from the cached template. If it is not found then a new template is created and put into the cache using the supplied XSLT System ID string as the key.

Parameters:
xsltURISystemID - XSLT stylesheet file to be parsed and cached. Also acts as the cache key.
Returns:
A parsed single use thread safe transformation object for the given stylesheet.
Throws:
javax.xml.transform.TransformerConfigurationException
java.io.FileNotFoundException