@ComponentProfile(summary="Execute an XSLT transform", tag="service,transform,xml") public class XmlTransformService extends ServiceImp
Implementation of Service
which provides transformation of XML payloads.
You are required to configure the XML transformer factory; see the javadoc and implementations of XmlTransformerFactory
for details on the supported transformer factories.
Configuration including allow over-ride behaviour matches previous implementation.
In the adapter configuration file this class is aliased as xml-transform-service which is the preferred alternative to the fully qualified classname when building your configuration.
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
XmlTransformService()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
java.lang.Boolean |
getAllowOverride()
Returns true if a configured XSLT URL may be over-ridden by one stored against a metadata key.
|
java.lang.Boolean |
getCacheTransforms()
Returns true if XSLTs should be cached.
|
java.lang.String |
getMetadataKey()
Returns the metadata key against which an over-ride XSLT URL may be stored.
|
java.lang.String |
getOutputMessageEncoding() |
XmlTransformParameter |
getTransformParameter() |
java.lang.String |
getUrl()
Returns the URL of the XSLT to use.
|
XmlTransformerFactory |
getXmlTransformerFactory() |
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
setAllowOverride(java.lang.Boolean b)
Sets whether the configured XSLT URL may be over-ridden by one stored against a metaddata key.
|
void |
setCacheTransforms(java.lang.Boolean b)
Sets whether XSLTs should be cached or not.
|
void |
setMetadataKey(java.lang.String s)
Sets the metadata key against which an over-ride XSLT URL may be stored.
|
void |
setOutputMessageEncoding(java.lang.String s)
Force the output message encoding to be a particular encoding.
|
void |
setTransformParameter(XmlTransformParameter param) |
void |
setUrl(java.lang.String s)
Sets the URL of the XSLT to use.
|
void |
setXmlTransformerFactory(XmlTransformerFactory xmlTransformerFactory) |
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsConfirmation, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isBranching, isConfirmation, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, rethrowServiceException, retrieveComponentState, setContinueOnFail, setIsConfirmation, setIsTrackingEndpoint, setLookupName, setUniqueId, start, stop
public XmlTransformService()
Creates a new instance. Defaults to caching transforms and not allowing over-rides. Default metadata key is
transformurl
.
protected void initService() throws CoreException
initService
in class ServiceImp
CoreException
protected void closeService()
closeService
in class ServiceImp
public void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
s(com.adaptris.core.AdaptrisMessage)
public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
public java.lang.String getUrl()
Returns the URL of the XSLT to use.
public void setUrl(java.lang.String s)
Sets the URL of the XSLT to use. May not be empty.
s
- the URL of the XSLT to usepublic java.lang.String getMetadataKey()
Returns the metadata key against which an over-ride XSLT URL may be stored.
public void setMetadataKey(java.lang.String s)
Sets the metadata key against which an over-ride XSLT URL may be stored. May not be empty.
s
- the metadata key against which an over-ride XSLT URL may be stored, defaults to
"transformurl"public java.lang.Boolean getCacheTransforms()
Returns true if XSLTs should be cached.
setCacheTransforms(Boolean)
public void setCacheTransforms(java.lang.Boolean b)
Sets whether XSLTs should be cached or not. If this is false the XSLT will be read for each message processed. Therefore while any changes to the XSLT will be picked up immediately, processing will take significantly longer, particularly if the XSLT is on a remote machine.
b
- whether XSLTs should be cached or not, defaults to true.public java.lang.Boolean getAllowOverride()
Returns true if a configured XSLT URL may be over-ridden by one stored against a metadata key.
public void setAllowOverride(java.lang.Boolean b)
Sets whether the configured XSLT URL may be over-ridden by one stored against a metaddata key. If URL is configured this is implicitly true.
b
- whether the configured XSLT URL may be over-ridden by one stored against a metaddata key, defaults to null (false)public java.lang.String getOutputMessageEncoding()
public void setOutputMessageEncoding(java.lang.String s)
If specified then the underlying AdaptrisMessage.setCharEncoding(String)
is changed to match the encoding specified
here before attempting any write operations.
This is only useful if the underlying message is encoded in one way, and you wish to force the encoding directly in your stylesheet; e.g. the message is physically encoded using ISO-8859-1; but your xslt has <xsl:output method="xml" encoding="UTF-8" indent="yes"/> and you need to ensure that the message is physically encoded using UTF-8 after the transform.
s
- the output encoding; if null, the the existing encoding specified by AdaptrisMessage.getCharEncoding()
is
used.public XmlTransformerFactory getXmlTransformerFactory()
public void setXmlTransformerFactory(XmlTransformerFactory xmlTransformerFactory)
public XmlTransformParameter getTransformParameter()
public void setTransformParameter(XmlTransformParameter param)