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,
remote=false,
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 TypeMethodDescriptionvoidprotected voidconfigureOutput(XsltBuilder xslt, String output) protected XsltBuildercreateBuilderForCustomStylesheet(String template, org.apache.camel.Exchange exchange) protected XsltBuilderprotected voiddoInit()protected voiddoStart()protected voiddoStop()findOrCreateEndpoint(String uri, String newResourceUri) intgetXslt()booleanbooleanbooleanbooleanbooleanbooleanprotected voidloadResource(String resourceUri, XsltBuilder xslt) Loads the resource.protected voidonExchange(org.apache.camel.Exchange exchange) voidsetAllowTemplateFromHeader(boolean allowTemplateFromHeader) Whether to allow to use resource template from header or not (default false).voidsetCacheCleared(boolean cacheCleared) voidsetContentCache(boolean contentCache) Cache for the resource content (the stylesheet file) when it is loaded on startup.voidsetDeleteOutputFile(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.voidsetEntityResolver(EntityResolver entityResolver) To use a custom org.xml.sax.EntityResolver with javax.xml.transform.sax.SAXSource.voidsetErrorListener(ErrorListener errorListener) Allows to configure to use a custom javax.xml.transform.ErrorListener.voidsetFailOnNullBody(boolean failOnNullBody) Whether or not to throw an exception if the input body is null.voidsetOutput(XsltOutput output) Option to specify which output type to use.voidsetParameters(Map<String, Object> parameters) Additional parameters to configure on the javax.xml.transform.Transformer.voidsetResourceUri(String resourceUri) Path to the template.voidsetResultHandlerFactory(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.voidsetTransformerCacheSize(int transformerCacheSize) The number of javax.xml.transform.Transformer object that are cached for reuse to avoid calls to Template.newTransformer().voidsetTransformerFactory(TransformerFactory transformerFactory) To use a custom XSLT transformer factoryvoidsetTransformerFactoryClass(String transformerFactoryClass) To use a custom XSLT transformer factory, specified as a FQN class namevoidsetTransformerFactoryConfigurationStrategy(TransformerFactoryConfigurationStrategy transformerFactoryConfigurationStrategy) A configuration strategy to apply on freshly created instances of TransformerFactory.voidsetUriResolver(URIResolver uriResolver) To use a custom javax.xml.transform.URIResolvervoidsetXslt(XsltBuilder xslt) voidsetXsltMessageLogger(XsltMessageLogger xsltMessageLogger) A consumer to messages generated during XSLT transformations.Methods inherited from class org.apache.camel.support.ProcessorEndpoint
createPollingConsumer, createProcessor, createProducer, getProcessor, setProcessorMethods inherited from class org.apache.camel.support.DefaultPollingEndpoint
createConsumerMethods 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, setUseFixedDelayMethods 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, toStringMethods 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, suspendMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.ComponentAware
getComponentMethods inherited from interface org.apache.camel.Endpoint
getEndpointBaseUri, isSingletonProducerMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods 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:
onExchangein classorg.apache.camel.support.ProcessorEndpoint- Throws:
Exception
-
createBuilderForCustomStylesheet
protected XsltBuilder createBuilderForCustomStylesheet(String template, org.apache.camel.Exchange exchange) throws Exception - Throws:
Exception
-
isAllowTemplateFromHeader
@ManagedAttribute(description="Whether to allow to use resource template from header or not (default false).") public boolean isAllowTemplateFromHeader() -
setAllowTemplateFromHeader
public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. -
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 on startup.") public boolean isContentCache() -
setContentCache
public void setContentCache(boolean contentCache) Cache for the resource content (the stylesheet file) when it is loaded on startup. 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:
doInitin classorg.apache.camel.support.DefaultEndpoint- Throws:
Exception
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
createXsltBuilder
- Throws:
Exception
-
configureOutput
- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-