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
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closing the Pool doesn't automatically mean all references remaining in the pool will be terminated.static TransformerPoolconfigureStyleSheetTransformer(FrankElement scopeProvider, String styleSheetName, int xsltVersion) static TransformerPoolconfigureTransformer(FrankElement scopeProvider, String namespaceDefs, String xPathExpression, String styleSheetName, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params) static TransformerPoolconfigureTransformer(FrankElement scopeProvider, String namespaceDefs, String xPathExpression, String styleSheetName, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params, boolean mandatory) static TransformerPoolconfigureTransformer0(FrankElement scopeProvider, String namespaceDefs, String xPathExpression, String styleSheetName, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params, int xsltVersion) protected Transformerstatic TransformerPoolgetInstance(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 TransformerPoolgetInstance(Resource resource) Get a TransformerPool instance that loads its XSLT stylesheet from the given resource.static TransformerPoolgetInstance(Resource resource, int xsltVersion) Get a TransformerPool instance that loads its XSLT stylesheet from the given resource.protected TransformergetTransformerFilter(ThreadConnector<?> threadConnector, ContentHandler handler) getTransformerFilter(ContentHandler handler) getTransformerFilter(ContentHandler handler, boolean removeNamespacesFromInput, boolean handleLexicalEvents) static TransformerPoolgetUtilityInstance(String xsltString, int xsltVersion) Special utility method to create a new TransformerPool without a ClassLoader.static TransformerPoolgetXPathTransformerPool(String xpathExpression, int xsltVersion) static TransformerPoolgetXPathTransformerPool(String namespaceDefs, String xpathExpression, TransformerPool.OutputType outputMethod) static TransformerPoolgetXPathTransformerPool(String namespaceDefs, String xPathExpression, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params) static TransformerPoolgetXPathTransformerPool(String namespaceDefs, String xPathExpression, TransformerPool.OutputType outputType, boolean includeXmlDeclaration, ParameterList params, int xsltVersion) protected voidprotected voidinvalidateTransformerNoThrow(Transformer transformer) voidopen()protected voidvoidTransforms Frank messages.transform(Message message, ParameterValueList pvl) transformToString(String s, Map<String, Object> parameters) transformToString(String s, Map<String, Object> parameters, boolean namespaceAware) transformToString(Source s, Map<String, Object> parameters) transformToString(Message input) transformToString(Message m, Map<String, Object> parameters, boolean namespaceAware)
-
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- TheIScopeProviderfor 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-Resourcefrom 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 thexlstVersionparameter, or be0for dynamic derivation at a performance penalty.- Parameters:
resource- TheResourcefrom 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 FrankElement 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 FrankElement 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 FrankElement 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 FrankElement 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
-
transformToString
public String transformToString(Message m, Map<String, Object> parameters, boolean namespaceAware) throws TransformerException, IOException, SAXException -
transformToString
-
transformToString
public String transformToString(String s, Map<String, Object> parameters) throws TransformerException, IOException, SAXException -
transformToString
public String transformToString(String s, Map<String, Object> parameters, boolean namespaceAware) throws TransformerException, IOException, SAXException -
transformToString
- Throws:
TransformerExceptionIOException
-
transformToString
public String transformToString(Source s, Map<String, Object> parameters) throws TransformerException, IOException- Throws:
TransformerExceptionIOException
-
transformToString
public String transformToString(@Nonnull Message input) throws TransformerException, IOException, SAXException -
transform
@Nonnull public Message transform(@Nonnull Message message) throws IOException, TransformerException, SAXException -
transform
@Nonnull public Message transform(@Nonnull Message message, @Nullable ParameterValueList pvl) throws IOException, TransformerException, SAXException -
transform
@Nonnull public Message transform(@Nonnull Message m, @Nullable Map<String, Object> parameterMap) throws IOException, TransformerException, SAXExceptionTransforms Frank messages. -
transform
public void transform(@Nonnull Source s, @Nonnull Result r, Map<String, Object> parameters) throws TransformerException, IOException- Throws:
TransformerExceptionIOException
-
getTransformerFilter
public TransformerFilter getTransformerFilter(@Nonnull ContentHandler handler) throws TransformerConfigurationException -
getTransformerFilter
public TransformerFilter getTransformerFilter(@Nonnull ContentHandler handler, boolean removeNamespacesFromInput, boolean handleLexicalEvents) throws TransformerConfigurationException -
getTransformerFilter
public TransformerFilter getTransformerFilter(@Nonnull ThreadConnector<?> threadConnector, @Nonnull ContentHandler handler) throws TransformerConfigurationException -
getConfigMap
- Throws:
TransformerExceptionIOException
-
getOmitXmlDeclaration
- Throws:
TransformerExceptionIOException
-
getIndent
- Throws:
TransformerExceptionIOException
-
getOutputMethod
- Throws:
TransformerExceptionIOException
-
getDisableOutputEscaping
- Throws:
TransformerExceptionIOException
-