Package org.frankframework.util
Class TransformerPool
java.lang.Object
org.frankframework.util.TransformerPool
Pool of transformers. As of IBIS 4.2.e the Templates object is used to
improve performance and work around threading problems with the api.
- Author:
- Gerrit van Brakel
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closing the Pool doesn't automatically mean all references remaining in the pool will be terminated.static TransformerPool
configureStyleSheetTransformer
(IConfigurationAware scopeProvider, String styleSheetName, int xsltVersion) static TransformerPool
configureTransformer
(IConfigurationAware scopeProvider, String namespaceDefs, String xPathExpression, String styleSheetName, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params) static TransformerPool
configureTransformer
(IConfigurationAware scopeProvider, String namespaceDefs, String xPathExpression, String styleSheetName, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params, boolean mandatory) static TransformerPool
configureTransformer0
(IConfigurationAware scopeProvider, String namespaceDefs, String xPathExpression, String styleSheetName, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params, int xsltVersion) protected Transformer
Deprecated.only used in Parameter, need to refactor that first...static TransformerPool
getInstance
(String xsltString, int xsltVersion, IScopeProvider scopeProvider) Get an instance of a TransformerPool that can load additional resources such as referenced URIs from the providedIScopeProvider
.static TransformerPool
getInstance
(Resource resource) Get a TransformerPool instance that loads its XSLT stylesheet from the given resource.static TransformerPool
getInstance
(Resource resource, int xsltVersion) Get a TransformerPool instance that loads its XSLT stylesheet from the given resource.protected Transformer
getTransformerFilter
(ThreadConnector<?> threadConnector, ContentHandler handler) getTransformerFilter
(ThreadConnector<?> threadConnector, ContentHandler handler, boolean removeNamespacesFromInput, boolean handleLexicalEvents) static TransformerPool
getUtilityInstance
(String xsltString, int xsltVersion) Special utility method to create a new TransformerPool without a ClassLoader.static TransformerPool
getXPathTransformerPool
(String xpathExpression, int xsltVersion) static TransformerPool
getXPathTransformerPool
(String namespaceDefs, String xpathExpression, TransformerPool.OutputType outputMethod) static TransformerPool
getXPathTransformerPool
(String namespaceDefs, String xPathExpression, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params) static TransformerPool
getXPathTransformerPool
(String namespaceDefs, String xPathExpression, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params, int xsltVersion) int
protected void
protected void
invalidateTransformerNoThrow
(Transformer transformer) void
open()
protected void
protected String
transform
(Message m, ParameterValueList pvl) Transforms Frank messages.
-
Field Details
-
log
protected static org.apache.logging.log4j.Logger log
-
-
Method Details
-
getInstance
public static TransformerPool getInstance(@Nonnull String xsltString, int xsltVersion, @Nullable IScopeProvider scopeProvider) throws TransformerConfigurationException Get an instance of a TransformerPool that can load additional resources such as referenced URIs from the providedIScopeProvider
. WARNING: This should only be used to be able to load Configuration-specific resources in dynamically loaded configurations. This should not be used for application-wide transformer pools.- Parameters:
xsltString
- The XSLT to be evaluated, as stringxsltVersion
- Version of XSLT. Can be 0, 1, or 2. If 0, the actual version will be extracted from the stylesheet at a performance-penalty.scopeProvider
- TheIScopeProvider
for loading additional resources- Returns:
- A TransformerPool instance for the input stylesheet.
- Throws:
TransformerConfigurationException
-
getUtilityInstance
public static TransformerPool getUtilityInstance(@Nonnull String xsltString, int xsltVersion) throws TransformerConfigurationException Special utility method to create a new TransformerPool without a ClassLoader. Utility pools should never use configuration classloaders, instead always read from the classpath! Utility pools should always be cached statically for re-use. The caller-code is responsible for this. -
getInstance
public static TransformerPool getInstance(@Nonnull Resource resource) throws TransformerConfigurationException, IOException Get a TransformerPool instance that loads its XSLT stylesheet from the given resource. The XSLT version will be dynamically derived from the stylesheet, at a performance penalty.- Parameters:
resource
-Resource
from which to load the stylesheet- Returns:
- TransformerPool instance for the XSLT stylesheet.
- Throws:
TransformerConfigurationException
- Thrown if there was an exception creating the TransformerPool or parsing the XSLT stylesheetIOException
- Thrown if the resource cannot be loaded
-
getInstance
public static TransformerPool getInstance(@Nonnull Resource resource, int xsltVersion) throws TransformerConfigurationException, IOException Get a TransformerPool instance that loads its XSLT stylesheet from the given resource. The XSLT version in the stylesheet should match thexlstVersion
parameter, or be0
for dynamic derivation at a performance penalty.- Parameters:
resource
- TheResource
from which to load the XSLT stylesheetxsltVersion
- The XSLT version of the stylesheet. Can be 0, 1, or 2. If 0, the actual version will be dynamically derived from the stylesheet itself on creation at a cost in performance.- Returns:
- TransformerPool instance for the XSLT stylesheet.
- Throws:
TransformerConfigurationException
- Thrown if there was an exception creating the TransformerPool or parsing the XSLT stylesheetIOException
- Thrown if the resource cannot be loaded
-
configureTransformer
@Nullable public static TransformerPool configureTransformer(@Nullable IConfigurationAware scopeProvider, @Nullable String namespaceDefs, @Nullable String xPathExpression, @Nullable String styleSheetName, @Nonnull TransformerPool.OutputType outputType, boolean includeXmlDeclaration, @Nullable ParameterList params, boolean mandatory) throws ConfigurationException - Throws:
ConfigurationException
-
configureTransformer
@Nonnull public static TransformerPool configureTransformer(@Nullable IConfigurationAware scopeProvider, @Nullable String namespaceDefs, @Nullable String xPathExpression, @Nullable String styleSheetName, @Nullable TransformerPool.OutputType outputType, boolean includeXmlDeclaration, @Nullable ParameterList params) throws ConfigurationException - Throws:
ConfigurationException
-
configureTransformer0
@Nonnull public static TransformerPool configureTransformer0(@Nullable IConfigurationAware scopeProvider, @Nullable String namespaceDefs, @Nullable String xPathExpression, @Nullable String styleSheetName, @Nonnull TransformerPool.OutputType outputType, boolean includeXmlDeclaration, @Nullable ParameterList params, int xsltVersion) throws ConfigurationException - Throws:
ConfigurationException
-
configureStyleSheetTransformer
@Nonnull public static TransformerPool configureStyleSheetTransformer(@Nullable IConfigurationAware scopeProvider, @Nullable String styleSheetName, int xsltVersion) throws ConfigurationException - Throws:
ConfigurationException
-
getXPathTransformerPool
@Nonnull public static TransformerPool getXPathTransformerPool(@Nonnull String xpathExpression, int xsltVersion) throws TransformerConfigurationException -
getXPathTransformerPool
@Nonnull public static TransformerPool getXPathTransformerPool(@Nullable String namespaceDefs, @Nonnull String xpathExpression, @Nonnull TransformerPool.OutputType outputMethod) throws TransformerConfigurationException -
getXPathTransformerPool
@Nonnull public static TransformerPool getXPathTransformerPool(@Nullable String namespaceDefs, @Nonnull String xPathExpression, @Nonnull TransformerPool.OutputType outputType, boolean includeXmlDeclaration, @Nullable ParameterList params) throws TransformerConfigurationException -
getXPathTransformerPool
@Nonnull public static TransformerPool getXPathTransformerPool(@Nullable String namespaceDefs, @Nonnull String xPathExpression, @Nonnull TransformerPool.OutputType outputType, boolean includeXmlDeclaration, @Nullable ParameterList params, int xsltVersion) throws TransformerConfigurationException -
open
public void open() -
close
public void close()Closing the Pool doesn't automatically mean all references remaining in the pool will be terminated. After closing, manually releases any associated resources in the pool -
getTransformer
-
releaseTransformer
-
invalidateTransformer
- Throws:
Exception
-
invalidateTransformerNoThrow
-
createTransformer
-
transform
public String transform(Message m, Map<String, Object> parameters, boolean namespaceAware) throws TransformerException, IOException, SAXException -
transform
-
transform
public String transform(String s, Map<String, Object> parameters) throws TransformerException, IOException, SAXException -
transform
public String transform(String s, Map<String, Object> parameters, boolean namespaceAware) throws TransformerException, IOException, SAXException -
transform
- Throws:
TransformerException
IOException
-
transform
public String transform(Source s, Map<String, Object> parameters) throws TransformerException, IOException- Throws:
TransformerException
IOException
-
transform
public String transform(@Nonnull Message input) throws TransformerException, IOException, SAXException -
transform
public Message transform(@Nonnull Message m, @Nullable ParameterValueList pvl) throws TransformerException, IOException, SAXException Transforms Frank messages. -
deprecatedParameterTransformAction
@Deprecated public String deprecatedParameterTransformAction(Source s, Result r, ParameterValueList pvl) throws TransformerException, IOException Deprecated.only used in Parameter, need to refactor that first... Renamed because of overloading issues. When method parameter 'Result' is used, nothing will be returned.- Throws:
TransformerException
IOException
-
transform
protected String transform(Source s, Result r, Map<String, Object> parameters) throws TransformerException, IOException- Throws:
TransformerException
IOException
-
getTransformerHandler
-
getTransformerFilter
public TransformerFilter getTransformerFilter(ThreadConnector<?> threadConnector, ContentHandler handler) throws TransformerConfigurationException -
getTransformerFilter
public TransformerFilter getTransformerFilter(ThreadConnector<?> threadConnector, ContentHandler handler, boolean removeNamespacesFromInput, boolean handleLexicalEvents) throws TransformerConfigurationException -
getConfigMap
- Throws:
TransformerException
IOException
-
getOmitXmlDeclaration
- Throws:
TransformerException
IOException
-
getIndent
- Throws:
TransformerException
IOException
-
getOutputMethod
- Throws:
TransformerException
IOException
-
getDisableOutputEscaping
- Throws:
TransformerException
IOException
-
getXsltVersion
public int getXsltVersion()
-