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
    Constructor
    Description
    XsltEndpoint(String endpointUri, org.apache.camel.Component component)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected void
     
    protected XsltBuilder
     
    protected void
     
    protected void
     
    protected void
     
    findOrCreateEndpoint(String uri, String newResourceUri)
     
     
     
     
     
     
     
    int
     
     
     
     
     
     
     
    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
    To use a custom org.xml.sax.EntityResolver with javax.xml.transform.sax.SAXSource.
    void
    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
    Option to specify which output type to use.
    void
    Additional parameters to configure on the javax.xml.transform.Transformer.
    void
    setResourceUri(String resourceUri)
    Path to the template.
    void
    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
    To use a custom XSLT transformer factory
    void
    setTransformerFactoryClass(String transformerFactoryClass)
    To use a custom XSLT transformer factory, specified as a FQN class name
    void
    A configuration strategy to apply on freshly created instances of TransformerFactory.
    void
    To use a custom javax.xml.transform.URIResolver
    void
     
    void
    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

      public XsltEndpoint(String endpointUri, org.apache.camel.Component component)
  • 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

      public XsltEndpoint findOrCreateEndpoint(String uri, String newResourceUri)
    • onExchange

      protected void onExchange(org.apache.camel.Exchange exchange) throws Exception
      Overrides:
      onExchange in class org.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 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

      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.
    • getParameters

      public Map<String,Object> getParameters()
    • 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.
    • getXsltMessageLogger

      public XsltMessageLogger getXsltMessageLogger()
    • setXsltMessageLogger

      public void setXsltMessageLogger(XsltMessageLogger xsltMessageLogger)
      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 resource
      IOException - is thrown if error loading resource
    • doInit

      protected void doInit() throws Exception
      Overrides:
      doInit in class org.apache.camel.support.DefaultEndpoint
      Throws:
      Exception
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • createXsltBuilder

      protected XsltBuilder createXsltBuilder() throws Exception
      Throws:
      Exception
    • configureOutput

      protected void configureOutput(XsltBuilder xslt, String output) throws Exception
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception