Package org.apache.camel.component.xslt
Class XsltEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.support.ScheduledPollEndpoint
-
- org.apache.camel.support.DefaultPollingEndpoint
-
- org.apache.camel.support.ProcessorEndpoint
-
- org.apache.camel.component.xslt.XsltEndpoint
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasId
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@ManagedResource(description="Managed XsltEndpoint") @UriEndpoint(firstVersion="1.3.0", scheme="xslt", title="XSLT", syntax="xslt:resourceUri", producerOnly=true, label="core,transformation") public class XsltEndpoint extends org.apache.camel.support.ProcessorEndpoint
Transforms XML payload using an XSLT template.
-
-
Constructor Summary
Constructors Constructor Description XsltEndpoint(String endpointUri, org.apache.camel.Component component)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCachedStylesheet()
protected void
configureOutput(XsltBuilder xslt, String output)
protected XsltBuilder
createXsltBuilder()
protected void
doInit()
protected void
doStart()
protected void
doStop()
XsltEndpoint
findOrCreateEndpoint(String uri, String newResourceUri)
EntityResolver
getEntityResolver()
ErrorListener
getErrorListener()
XsltOutput
getOutput()
Map<String,Object>
getParameters()
String
getResourceUri()
ResultHandlerFactory
getResultHandlerFactory()
int
getTransformerCacheSize()
TransformerFactory
getTransformerFactory()
String
getTransformerFactoryClass()
TransformerFactoryConfigurationStrategy
getTransformerFactoryConfigurationStrategy()
URIResolver
getUriResolver()
XsltBuilder
getXslt()
boolean
isCacheCleared()
boolean
isCacheStylesheet()
boolean
isContentCache()
boolean
isDeleteOutputFile()
boolean
isFailOnNullBody()
protected void
loadResource(String resourceUri, XsltBuilder xslt)
Loads the resource.protected void
onExchange(org.apache.camel.Exchange exchange)
void
setCacheCleared(boolean cacheCleared)
void
setContentCache(boolean contentCache)
Cache for the resource content (the stylesheet file) when it is loaded.void
setDeleteOutputFile(boolean deleteOutputFile)
If you have output=file then this option dictates whether or not the output file should be deleted when the Exchange is done processing.void
setEntityResolver(EntityResolver entityResolver)
To use a custom org.xml.sax.EntityResolver with javax.xml.transform.sax.SAXSource.void
setErrorListener(ErrorListener errorListener)
Allows to configure to use a custom javax.xml.transform.ErrorListener.void
setFailOnNullBody(boolean failOnNullBody)
Whether or not to throw an exception if the input body is null.void
setOutput(XsltOutput output)
Option to specify which output type to use.void
setParameters(Map<String,Object> parameters)
Additional parameters to configure on the javax.xml.transform.Transformer.void
setResourceUri(String resourceUri)
Path to the template.void
setResultHandlerFactory(ResultHandlerFactory resultHandlerFactory)
Allows you to use a custom org.apache.camel.builder.xml.ResultHandlerFactory which is capable of using custom org.apache.camel.builder.xml.ResultHandler types.void
setTransformerCacheSize(int transformerCacheSize)
The number of javax.xml.transform.Transformer object that are cached for reuse to avoid calls to Template.newTransformer().void
setTransformerFactory(TransformerFactory transformerFactory)
To use a custom XSLT transformer factoryvoid
setTransformerFactoryClass(String transformerFactoryClass)
To use a custom XSLT transformer factory, specified as a FQN class namevoid
setTransformerFactoryConfigurationStrategy(TransformerFactoryConfigurationStrategy transformerFactoryConfigurationStrategy)
A configuration strategy to apply on freshly created instances of TransformerFactory.void
setUriResolver(URIResolver uriResolver)
To use a custom javax.xml.transform.URIResolvervoid
setXslt(XsltBuilder xslt)
-
Methods inherited from class org.apache.camel.support.ProcessorEndpoint
createPollingConsumer, createProcessor, createProducer, getProcessor, setProcessor
-
Methods inherited from class org.apache.camel.support.ScheduledPollEndpoint
configureConsumer, configureProperties, configureScheduledPollConsumerProperties, doConfigureConsumer, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getDefaultDelay, getDelay, getInitialDelay, getPollStrategy, getRepeatCount, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getTimeUnit, isGreedy, isSendEmptyMessageWhenIdle, isStartScheduler, isUseFixedDelay, setBackoffErrorThreshold, setBackoffIdleThreshold, setBackoffMultiplier, setDelay, setGreedy, setInitialDelay, setPollStrategy, setRepeatCount, setRunLoggingLevel, setScheduledExecutorService, setScheduler, setSchedulerProperties, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay
-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configurePollingConsumer, createAsyncProducer, createEndpointUri, createExchange, createExchange, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isSingleton, isSynchronous, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, toString
-
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, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
XsltEndpoint
public XsltEndpoint(String endpointUri, org.apache.camel.Component component)
-
-
Method Detail
-
clearCachedStylesheet
@ManagedOperation(description="Clears the cached XSLT stylesheet, forcing to re-load the stylesheet on next request") public void clearCachedStylesheet()
-
isCacheStylesheet
@ManagedAttribute(description="Whether the XSLT stylesheet is cached") public boolean isCacheStylesheet()
-
findOrCreateEndpoint
public XsltEndpoint findOrCreateEndpoint(String uri, String newResourceUri)
-
onExchange
protected void onExchange(org.apache.camel.Exchange exchange) throws Exception
- Overrides:
onExchange
in classorg.apache.camel.support.ProcessorEndpoint
- Throws:
Exception
-
isCacheCleared
public boolean isCacheCleared()
-
setCacheCleared
public void setCacheCleared(boolean cacheCleared)
-
getXslt
public XsltBuilder getXslt()
-
setXslt
public void setXslt(XsltBuilder xslt)
-
getResourceUri
@ManagedAttribute(description="Path to the template") public String getResourceUri()
-
setResourceUri
public void setResourceUri(String resourceUri)
Path to the template. The following is supported by the default URIResolver. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod- Parameters:
resourceUri
- the resource path
-
getTransformerFactoryClass
public String getTransformerFactoryClass()
-
setTransformerFactoryClass
public void setTransformerFactoryClass(String transformerFactoryClass)
To use a custom XSLT transformer factory, specified as a FQN class name
-
getTransformerFactory
public TransformerFactory getTransformerFactory()
-
setTransformerFactory
public void setTransformerFactory(TransformerFactory transformerFactory)
To use a custom XSLT transformer factory
-
getResultHandlerFactory
public ResultHandlerFactory getResultHandlerFactory()
-
setResultHandlerFactory
public void setResultHandlerFactory(ResultHandlerFactory resultHandlerFactory)
Allows you to use a custom org.apache.camel.builder.xml.ResultHandlerFactory which is capable of using custom org.apache.camel.builder.xml.ResultHandler types.
-
isFailOnNullBody
@ManagedAttribute(description="Whether or not to throw an exception if the input body is null") public boolean isFailOnNullBody()
-
setFailOnNullBody
public void setFailOnNullBody(boolean failOnNullBody)
Whether or not to throw an exception if the input body is null.
-
getOutput
@ManagedAttribute(description="What kind of option to use.") public XsltOutput getOutput()
-
setOutput
public void setOutput(XsltOutput output)
Option to specify which output type to use. Possible values are: string, bytes, DOM, file. The first three options are all in memory based, where as file is streamed directly to a java.io.File. For file you must specify the filename in the IN header with the key Exchange.XSLT_FILE_NAME which is also CamelXsltFileName. Also any paths leading to the filename must be created beforehand, otherwise an exception is thrown at runtime.
-
getTransformerCacheSize
public int getTransformerCacheSize()
-
setTransformerCacheSize
public void setTransformerCacheSize(int transformerCacheSize)
The number of javax.xml.transform.Transformer object that are cached for reuse to avoid calls to Template.newTransformer().
-
getErrorListener
public ErrorListener getErrorListener()
-
setErrorListener
public void setErrorListener(ErrorListener errorListener)
Allows to configure to use a custom javax.xml.transform.ErrorListener. Beware when doing this then the default error listener which captures any errors or fatal errors and store information on the Exchange as properties is not in use. So only use this option for special use-cases.
-
isContentCache
@ManagedAttribute(description="Cache for the resource content (the stylesheet file) when it is loaded.") public boolean isContentCache()
-
setContentCache
public void setContentCache(boolean contentCache)
Cache for the resource content (the stylesheet file) when it is loaded. If set to false Camel will reload the stylesheet file on each message processing. This is good for development. A cached stylesheet can be forced to reload at runtime via JMX using the clearCachedStylesheet operation.
-
getUriResolver
public URIResolver getUriResolver()
-
setUriResolver
public void setUriResolver(URIResolver uriResolver)
To use a custom javax.xml.transform.URIResolver
-
isDeleteOutputFile
public boolean isDeleteOutputFile()
-
setDeleteOutputFile
public void setDeleteOutputFile(boolean deleteOutputFile)
If you have output=file then this option dictates whether or not the output file should be deleted when the Exchange is done processing. For example suppose the output file is a temporary file, then it can be a good idea to delete it after use.
-
getEntityResolver
public EntityResolver getEntityResolver()
-
setEntityResolver
public void setEntityResolver(EntityResolver entityResolver)
To use a custom org.xml.sax.EntityResolver with javax.xml.transform.sax.SAXSource.
-
setParameters
public void setParameters(Map<String,Object> parameters)
Additional parameters to configure on the javax.xml.transform.Transformer.
-
getTransformerFactoryConfigurationStrategy
public TransformerFactoryConfigurationStrategy getTransformerFactoryConfigurationStrategy()
-
setTransformerFactoryConfigurationStrategy
public void setTransformerFactoryConfigurationStrategy(TransformerFactoryConfigurationStrategy transformerFactoryConfigurationStrategy)
A configuration strategy to apply on freshly created instances of TransformerFactory.
-
loadResource
protected void loadResource(String resourceUri, XsltBuilder xslt) 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
-
doInit
protected void doInit() throws Exception
- Overrides:
doInit
in classorg.apache.camel.support.DefaultEndpoint
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.ScheduledPollEndpoint
- Throws:
Exception
-
createXsltBuilder
protected XsltBuilder createXsltBuilder() throws Exception
- Throws:
Exception
-
configureOutput
protected void configureOutput(XsltBuilder xslt, String output) throws Exception
- Throws:
Exception
-
-