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.CamelContextAware
The 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:setPropertyName(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.Exchange
aggregate(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
protected void
configureOutput(XsltBuilder xslt, String output)
static XsltAggregationStrategy
create(String xslFile)
protected XsltBuilder
createXsltBuilder()
protected void
doInit()
protected void
doStart()
protected void
doStop()
org.apache.camel.CamelContext
getCamelContext()
String
getPropertyName()
protected void
loadResource(String resourceUri)
Loads the resource.void
setCamelContext(org.apache.camel.CamelContext camelContext)
void
setOutput(XsltOutput output)
void
setPropertyName(String propertyName)
void
setTransformerFactory(TransformerFactory transformerFactory)
void
setTransformerFactoryClass(String transformerFactoryClass)
void
setUriResolver(URIResolver uriResolver)
void
setXslt(XsltBuilder xslt)
XsltAggregationStrategy
withOutput(XsltOutput output)
XsltAggregationStrategy
withPropertyName(String propertyName)
XsltAggregationStrategy
withTransformerFactoryClass(String clazz)
XsltAggregationStrategy
withUriResolver(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:
getCamelContext
in interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContext
in interfaceorg.apache.camel.CamelContextAware
-
aggregate
public org.apache.camel.Exchange aggregate(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
- Specified by:
aggregate
in 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:
doInit
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
-