Package org.apache.camel.component.xslt
Class XsltAggregationStrategy
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.component.xslt.XsltAggregationStrategy
-
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.AggregationStrategy,org.apache.camel.CamelContextAware,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
public class XsltAggregationStrategy extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.AggregationStrategy, org.apache.camel.CamelContextAwareThe XSLT Aggregation Strategy enables you to use XSL stylesheets to aggregate messages.Since XSLT does not directly support providing multiple XML payloads as an input, this aggregator injects the new incoming XML document (newExchange) into the oldExchange as an exchange property of type
Document. The old exchange therefore remains accessible as the root context. This exchange property can then be accessed from your XSLT by declaring an<xsl:param />at the top of your stylesheet:The exchange property name defaults to new-exchange but can be changed throughsetPropertyName(String).Some code bits have been copied from the
XsltEndpoint.
-
-
Constructor Summary
Constructors Constructor Description XsltAggregationStrategy(String xslFileLocation)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.camel.Exchangeaggregate(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)protected voidconfigureOutput(XsltBuilder xslt, String output)static XsltAggregationStrategycreate(String xslFile)protected XsltBuildercreateXsltBuilder()protected voiddoInit()protected voiddoStart()protected voiddoStop()org.apache.camel.CamelContextgetCamelContext()StringgetPropertyName()protected voidloadResource(String resourceUri)Loads the resource.voidsetCamelContext(org.apache.camel.CamelContext camelContext)voidsetOutput(XsltOutput output)voidsetPropertyName(String propertyName)voidsetTransformerFactory(TransformerFactory transformerFactory)voidsetTransformerFactoryClass(String transformerFactoryClass)voidsetUriResolver(URIResolver uriResolver)voidsetXslt(XsltBuilder xslt)XsltAggregationStrategywithOutput(XsltOutput output)XsltAggregationStrategywithPropertyName(String propertyName)XsltAggregationStrategywithTransformerFactoryClass(String clazz)XsltAggregationStrategywithUriResolver(URIResolver resolver)-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.camel.AggregationStrategy
aggregate, canPreComplete, onCompletion, onOptimisticLockFailure, preComplete, timeout
-
-
-
-
Constructor Detail
-
XsltAggregationStrategy
public XsltAggregationStrategy(String xslFileLocation)
Constructor.- Parameters:
xslFileLocation- location of the XSL transformation
-
-
Method Detail
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
aggregate
public org.apache.camel.Exchange aggregate(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)- Specified by:
aggregatein interfaceorg.apache.camel.AggregationStrategy
-
setOutput
public void setOutput(XsltOutput output)
-
setXslt
public void setXslt(XsltBuilder xslt)
-
setUriResolver
public void setUriResolver(URIResolver uriResolver)
-
setTransformerFactoryClass
public void setTransformerFactoryClass(String transformerFactoryClass)
-
setTransformerFactory
public void setTransformerFactory(TransformerFactory transformerFactory)
-
getPropertyName
public String getPropertyName()
-
setPropertyName
public void setPropertyName(String propertyName)
-
configureOutput
protected void configureOutput(XsltBuilder xslt, String output) throws Exception
- Throws:
Exception
-
loadResource
protected void loadResource(String resourceUri) throws TransformerException, IOException
Loads the resource.- Parameters:
resourceUri- the resource to load- Throws:
TransformerException- is thrown if error loading resourceIOException- is thrown if error loading resource
-
create
public static XsltAggregationStrategy create(String xslFile)
-
withPropertyName
public XsltAggregationStrategy withPropertyName(String propertyName)
-
withOutput
public XsltAggregationStrategy withOutput(XsltOutput output)
-
withUriResolver
public XsltAggregationStrategy withUriResolver(URIResolver resolver)
-
withTransformerFactoryClass
public XsltAggregationStrategy withTransformerFactoryClass(String clazz)
-
createXsltBuilder
protected XsltBuilder createXsltBuilder()
-
doInit
protected void doInit() throws Exception- Overrides:
doInitin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
-