Spring Integration

org.springframework.integration.xml.transformer
Class XsltPayloadTransformer

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.transformer.AbstractTransformer
          extended by org.springframework.integration.xml.transformer.XsltPayloadTransformer
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, NamedComponent, Transformer

public class XsltPayloadTransformer
extends AbstractTransformer

Thread safe XSLT transformer implementation which returns a transformed Source, Document, or String. If alwaysUseSourceResultFactories is false (default) the following logic occurs

String payload in results in String payload out

Document payload in results in Document payload out

Source payload in results in Result payload out, type will be determined by the ResultFactory, DomResultFactory by default. If an instance of ResultTransformer is registered this will be used to convert the result.

If alwaysUseSourceResultFactories is true then the ResultFactory and SourceFactory will be used to create the Source from the payload and the Result to pass into the transformer. An instance of ResultTransformer can also be provided to convert the Result prior to returning.

Author:
Jonas Partner, Mark Fisher, Oleg Zhurakousky

Constructor Summary
XsltPayloadTransformer(org.springframework.core.io.Resource xslResource)
           
XsltPayloadTransformer(org.springframework.core.io.Resource xslResource, ResultTransformer resultTransformer)
           
XsltPayloadTransformer(javax.xml.transform.Templates templates)
           
XsltPayloadTransformer(javax.xml.transform.Templates templates, ResultTransformer resultTransformer)
           
 
Method Summary
protected  java.lang.Object doTransform(Message<?> message)
          Subclasses must implement this method to provide the transformation logic.
 java.lang.String getComponentType()
          Subclasses may implement this method to provide component type information.
 void setAlwaysUseResultFactory(boolean alwaysUseResultFactory)
          Specify whether to always use result factory even for directly supported payload types
 void setAlwaysUseSourceFactory(boolean alwaysUseSourceFactory)
          Specify whether to always use source factory even for directly supported payload types.
 void setResultFactory(ResultFactory resultFactory)
          Sets the ResultFactory
 void setSourceFactory(SourceFactory sourceFactory)
          Sets the SourceFactory.
 void setXslParameterMappings(java.util.Map<java.lang.String,org.springframework.expression.Expression> xslParameterMappings)
           
 void setXsltParamHeaders(java.lang.String[] xsltParamHeaders)
           
 
Methods inherited from class org.springframework.integration.transformer.AbstractTransformer
transform
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XsltPayloadTransformer

public XsltPayloadTransformer(javax.xml.transform.Templates templates)
                       throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException

XsltPayloadTransformer

public XsltPayloadTransformer(org.springframework.core.io.Resource xslResource)
                       throws java.lang.Exception
Throws:
java.lang.Exception

XsltPayloadTransformer

public XsltPayloadTransformer(org.springframework.core.io.Resource xslResource,
                              ResultTransformer resultTransformer)
                       throws java.lang.Exception
Throws:
java.lang.Exception

XsltPayloadTransformer

public XsltPayloadTransformer(javax.xml.transform.Templates templates,
                              ResultTransformer resultTransformer)
                       throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException
Method Detail

setSourceFactory

public void setSourceFactory(SourceFactory sourceFactory)
Sets the SourceFactory.


setResultFactory

public void setResultFactory(ResultFactory resultFactory)
Sets the ResultFactory


setAlwaysUseSourceFactory

public void setAlwaysUseSourceFactory(boolean alwaysUseSourceFactory)
Specify whether to always use source factory even for directly supported payload types.


setAlwaysUseResultFactory

public void setAlwaysUseResultFactory(boolean alwaysUseResultFactory)
Specify whether to always use result factory even for directly supported payload types


setXslParameterMappings

public void setXslParameterMappings(java.util.Map<java.lang.String,org.springframework.expression.Expression> xslParameterMappings)

setXsltParamHeaders

public void setXsltParamHeaders(java.lang.String[] xsltParamHeaders)

getComponentType

public java.lang.String getComponentType()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this method to provide component type information.

Specified by:
getComponentType in interface NamedComponent
Overrides:
getComponentType in class IntegrationObjectSupport

doTransform

protected java.lang.Object doTransform(Message<?> message)
                                throws java.lang.Exception
Description copied from class: AbstractTransformer
Subclasses must implement this method to provide the transformation logic. If the return value is itself a Message, it will be used as the result. Otherwise, any non-null return value will be used as the payload of the result Message.

Specified by:
doTransform in class AbstractTransformer
Throws:
java.lang.Exception

Spring Integration