Class ThymeleafEndpoint

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.ResourceEndpoint
org.apache.camel.component.thymeleaf.ThymeleafEndpoint
All Implemented Interfaces:
AutoCloseable, org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean, 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

@UriEndpoint(firstVersion="4.1.0", scheme="thymeleaf", title="Thymeleaf", syntax="thymeleaf:resourceUri", remote=false, producerOnly=true, category=TRANSFORMATION, headersClass=ThymeleafConstants.class) @Metadata(excludeProperties="contentCache") public class ThymeleafEndpoint extends org.apache.camel.component.ResourceEndpoint
Transform messages using a Thymeleaf template.
  • Field Summary

    Fields inherited from class org.apache.camel.component.ResourceEndpoint

    log

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ThymeleafEndpoint(String endpointURI, org.apache.camel.Component component, String resourceURI)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected String
     
    findOrCreateEndpoint(String uri, String newResourceUri)
     
     
     
     
     
    org.apache.camel.ExchangePattern
     
     
     
     
     
    protected org.thymeleaf.TemplateEngine
     
     
    boolean
     
    boolean
     
    protected void
    onExchange(org.apache.camel.Exchange exchange)
     
    void
    setAllowTemplateFromHeader(boolean allowTemplateFromHeader)
    Whether to allow to use resource template from header or not (default false).
    void
    setCacheable(Boolean cacheable)
    Sets a new value for the cacheable flag.
    void
    setCacheTimeToLive(Long cacheTimeToLive)
    Sets a new value for the cache TTL for resolved templates.
    void
    setCheckExistence(Boolean checkExistence)
    Sets whether template resources will be checked for existence before being returned or not.
    void
    setEncoding(String encoding)
    Sets a new character encoding for reading template resources.
    void
    setJakartaServletWebApplication(org.thymeleaf.web.servlet.JakartaServletWebApplication jakartaServletWebApplication)
     
    void
    Sets a new order for the template engine in the chain.
    void
    setPrefix(String prefix)
    Sets a new (optional) prefix to be added to all template names in order to convert template names into resource names.
    void
    Sets the type of resolver to be used by the template engine.
    void
    setSuffix(String suffix)
    Sets a new (optional) suffix to be added to all template names in order to convert template names into resource names.
    void
    setTemplate(String template)
     
    void
    setTemplateEngine(org.thymeleaf.TemplateEngine templateEngine)
    To use the TemplateEngine otherwise a new engine is created
    void
    setTemplateMode(String templateMode)
    Sets the template mode to be applied to templates resolved by this endpoint.

    Methods inherited from class org.apache.camel.component.ResourceEndpoint

    getCamelId, getCamelManagementName, getResourceAsInputStream, getResourceAsInputStreamWithoutCache, getResourceUri, getState, isAllowContextMapAll, isContentCache, isContentCacheCleared, loadResource, setAllowContextMapAll, setContentCache, setResourceUri

    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, createExchange, createExchange, doInit, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, 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, doStart, doStop, doSuspend, fail, getInternalLock, 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

    • ThymeleafEndpoint

      public ThymeleafEndpoint()
    • ThymeleafEndpoint

      public ThymeleafEndpoint(String endpointURI, org.apache.camel.Component component, String resourceURI)
  • Method Details

    • isRemote

      public boolean isRemote()
    • getExchangePattern

      public org.apache.camel.ExchangePattern getExchangePattern()
      Specified by:
      getExchangePattern in interface org.apache.camel.Endpoint
      Overrides:
      getExchangePattern in class org.apache.camel.support.DefaultEndpoint
    • createEndpointUri

      protected String createEndpointUri()
      Overrides:
      createEndpointUri in class org.apache.camel.support.DefaultEndpoint
    • getTemplateMode

      public String getTemplateMode()
    • setTemplateMode

      public void setTemplateMode(String templateMode)

      Sets the template mode to be applied to templates resolved by this endpoint.

      One of HTML, XML, TEXT, JAVASCRIPT, CSS, RAW.

      Note that this template mode will be ignored if the template resource name ends in a known file name suffix: .html, .htm, .xhtml, .xml, .js, .json, .css, .rss, .atom, .txt.

      Parameters:
      templateMode - the template mode.
    • getResolver

      public ThymeleafResolverType getResolver()
    • setResolver

      public void setResolver(ThymeleafResolverType resolver)
      Sets the type of resolver to be used by the template engine.

      One of CLASS_LOADER, DEFAULT, FILE, STRING, URL, WEB_APP.

    • getPrefix

      public String getPrefix()
    • setPrefix

      public void setPrefix(String prefix)

      Sets a new (optional) prefix to be added to all template names in order to convert template names into resource names.

      Parameters:
      prefix - the prefix to be set.
    • getSuffix

      public String getSuffix()
    • setSuffix

      public void setSuffix(String suffix)

      Sets a new (optional) suffix to be added to all template names in order to convert template names into resource names.

      Note that this suffix may not be applied to the template name if the template name already ends in a known file name suffix: .html, .htm, .xhtml, .xml, .js, .json, .css, .rss, .atom, .txt.

      Parameters:
      suffix - the suffix to be set.
    • getEncoding

      public String getEncoding()
    • setEncoding

      public void setEncoding(String encoding)
      Sets a new character encoding for reading template resources.
      Parameters:
      encoding - the character encoding to be used.
    • getOrder

      public Integer getOrder()
    • setOrder

      public void setOrder(Integer order)
      Sets a new order for the template engine in the chain. Order should start with 1.
      Parameters:
      order - the new order.
    • getCheckExistence

      public Boolean getCheckExistence()
    • setCheckExistence

      public void setCheckExistence(Boolean checkExistence)
      Sets whether template resources will be checked for existence before being returned or not. Default value is FALSE.
      Parameters:
      checkExistence - true if resource existence should be checked, false if not
    • getCacheTimeToLive

      public Long getCacheTimeToLive()
    • setCacheTimeToLive

      public void setCacheTimeToLive(Long cacheTimeToLive)
      Sets a new value for the cache TTL for resolved templates. If a template is resolved as cacheable but cache TTL is null, this means the template will live in cache until evicted by LRU (Least Recently Used) algorithm for being the oldest entry in cache.
      Parameters:
      cacheTimeToLive - the new cache TTL in milliseconds, or null for using natural LRU eviction.
    • getCacheable

      public Boolean getCacheable()
    • setCacheable

      public void setCacheable(Boolean cacheable)
      Sets a new value for the cacheable flag.
      Parameters:
      cacheable - whether resolved patterns should be considered cacheable or not.
    • isAllowTemplateFromHeader

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

      protected org.thymeleaf.TemplateEngine getTemplateEngine()
    • setTemplateEngine

      public void setTemplateEngine(org.thymeleaf.TemplateEngine templateEngine)
      To use the TemplateEngine otherwise a new engine is created
    • setJakartaServletWebApplication

      public void setJakartaServletWebApplication(org.thymeleaf.web.servlet.JakartaServletWebApplication jakartaServletWebApplication)
    • setTemplate

      public void setTemplate(String template)
    • clearContentCache

      public void clearContentCache()
      Specified by:
      clearContentCache in interface org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
      Overrides:
      clearContentCache in class org.apache.camel.component.ResourceEndpoint
    • findOrCreateEndpoint

      public ThymeleafEndpoint 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