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.ComponentAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasCamelContext
,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,
category={CORE,TRANSFORMATION},
headersClass=XsltConstants.class)
public class XsltEndpoint
extends org.apache.camel.support.ProcessorEndpoint
Transforms XML payload using an XSLT template.
-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
configureOutput
(XsltBuilder xslt, String output) protected XsltBuilder
protected void
doInit()
protected void
doStart()
protected void
doStop()
findOrCreateEndpoint
(String uri, String newResourceUri) int
getXslt()
boolean
boolean
boolean
boolean
boolean
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) void
setXsltMessageLogger
(XsltMessageLogger xsltMessageLogger) A consumer to messages generated during XSLT transformations.Methods inherited from class org.apache.camel.support.ProcessorEndpoint
createPollingConsumer, createProcessor, createProducer, getProcessor, setProcessor
Methods inherited from class org.apache.camel.support.DefaultPollingEndpoint
createConsumer
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
configureExchange, configurePollingConsumer, createAsyncProducer, createEndpointUri, createExchange, createExchange, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, 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
Methods inherited from interface org.apache.camel.ComponentAware
getComponent
Methods inherited from interface org.apache.camel.Endpoint
getEndpointBaseUri, isSingletonProducer
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
XsltEndpoint
-
-
Method Details
-
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
-
onExchange
- Overrides:
onExchange
in classorg.apache.camel.support.ProcessorEndpoint
- Throws:
Exception
-
isCacheCleared
public boolean isCacheCleared() -
setCacheCleared
public void setCacheCleared(boolean cacheCleared) -
getXslt
-
setXslt
-
getResourceUri
-
setResourceUri
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
-
setTransformerFactoryClass
To use a custom XSLT transformer factory, specified as a FQN class name -
getTransformerFactory
-
setTransformerFactory
To use a custom XSLT transformer factory -
getResultHandlerFactory
-
setResultHandlerFactory
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
-
setOutput
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 XsltConstants.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
-
setErrorListener
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
-
setUriResolver
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
-
setEntityResolver
To use a custom org.xml.sax.EntityResolver with javax.xml.transform.sax.SAXSource. -
getParameters
-
setParameters
Additional parameters to configure on the javax.xml.transform.Transformer. -
getTransformerFactoryConfigurationStrategy
-
setTransformerFactoryConfigurationStrategy
public void setTransformerFactoryConfigurationStrategy(TransformerFactoryConfigurationStrategy transformerFactoryConfigurationStrategy) A configuration strategy to apply on freshly created instances of TransformerFactory. -
getXsltMessageLogger
-
setXsltMessageLogger
A consumer to messages generated during XSLT transformations. -
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
- Overrides:
doInit
in classorg.apache.camel.support.DefaultEndpoint
- Throws:
Exception
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
createXsltBuilder
- Throws:
Exception
-
configureOutput
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-