public class XsltAggregationStrategy extends ServiceSupport implements AggregationStrategy, CamelContextAware
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 through setPropertyName(String).
Some code bits have been copied from the XsltEndpoint.
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending| Constructor and Description |
|---|
XsltAggregationStrategy(String xslFileLocation)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Exchange |
aggregate(Exchange oldExchange,
Exchange newExchange)
Aggregates an old and new exchange together to create a single combined exchange
|
protected void |
configureOutput(XsltBuilder xslt,
String output) |
static XsltAggregationStrategy |
create(String xslFile) |
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
String |
getPropertyName() |
protected void |
initialize(CamelContext context)
Deprecated.
|
protected void |
loadResource(String resourceUri)
Loads the resource.
|
void |
setCamelContext(CamelContext camelContext)
Injects the
CamelContext |
void |
setOutput(XsltOutput output) |
void |
setPropertyName(String propertyName) |
void |
setTransformerFactoryClass(String transformerFactoryClass) |
void |
setUriResolver(URIResolver uriResolver) |
void |
setXslt(XsltBuilder xslt) |
XsltAggregationStrategy |
withOutput(XsltOutput output) |
XsltAggregationStrategy |
withPropertyName(String propertyName) |
XsltAggregationStrategy |
withSaxon() |
XsltAggregationStrategy |
withTransformerFactoryClass(String clazz) |
XsltAggregationStrategy |
withUriResolver(URIResolver resolver) |
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendpublic XsltAggregationStrategy(String xslFileLocation)
xslFileLocation - location of the XSL transformationpublic CamelContext getCamelContext()
CamelContextAwareCamelContextgetCamelContext in interface CamelContextAwarepublic void setCamelContext(CamelContext camelContext)
CamelContextAwareCamelContextsetCamelContext in interface CamelContextAwarecamelContext - the Camel contextpublic Exchange aggregate(Exchange oldExchange, Exchange newExchange)
AggregationStrategyaggregate in interface AggregationStrategyoldExchange - the oldest exchange (is null on first aggregation as we only have the new exchange)newExchange - the newest exchange (can be null if there was no data possible to acquire)public void setOutput(XsltOutput output)
public void setXslt(XsltBuilder xslt)
public void setUriResolver(URIResolver uriResolver)
public void setTransformerFactoryClass(String transformerFactoryClass)
public String getPropertyName()
public void setPropertyName(String propertyName)
@Deprecated protected void initialize(CamelContext context) throws Exception
Exceptionprotected void configureOutput(XsltBuilder xslt, String output) throws Exception
Exceptionprotected void loadResource(String resourceUri) throws TransformerException, IOException
resourceUri - the resource to loadTransformerException - is thrown if error loading resourceIOException - is thrown if error loading resourcepublic static XsltAggregationStrategy create(String xslFile)
public XsltAggregationStrategy withPropertyName(String propertyName)
public XsltAggregationStrategy withOutput(XsltOutput output)
public XsltAggregationStrategy withUriResolver(URIResolver resolver)
public XsltAggregationStrategy withTransformerFactoryClass(String clazz)
public XsltAggregationStrategy withSaxon()
protected void doStart() throws Exception
ServiceSupportServiceSupport.doStop() for more details.doStart in class ServiceSupportExceptionServiceSupport.doStop()protected void doStop() throws Exception
ServiceSupportServiceSupport.doStop() method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext is shutting down.doStop in class ServiceSupportExceptionServiceSupport.doStart()Apache Camel