Class ResourceEndpoint

java.lang.Object
org.apache.camel.support.service.BaseService
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

@ManagedResource(description="Managed ResourceEndpoint") public abstract class ResourceEndpoint extends ProcessorEndpoint implements org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
A useful base class for endpoints which depend on a resource such as things like Velocity or XQuery based components.
  • Field Details

    • log

      protected final org.slf4j.Logger log
  • Constructor Details

    • ResourceEndpoint

      public ResourceEndpoint()
    • ResourceEndpoint

      public ResourceEndpoint(String endpointUri, org.apache.camel.Component component, String resourceUri)
  • Method Details

    • getResourceAsInputStream

      public InputStream getResourceAsInputStream() throws IOException
      Gets the resource as an input stream considering the cache flag as well.

      If cache is enabled then the resource content is cached in an internal buffer and this content is returned to avoid loading the resource over and over again.

      Returns:
      the input stream
      Throws:
      IOException - is thrown if error loading the content of the resource to the local cache buffer
    • getResourceAsInputStreamWithoutCache

      protected InputStream getResourceAsInputStreamWithoutCache() throws IOException
      Throws:
      IOException
    • loadResource

      protected InputStream loadResource(String uri) throws IOException
      Loads the given resource.
      Parameters:
      uri - uri of the resource.
      Returns:
      the loaded resource
      Throws:
      IOException - is thrown if resource is not found or cannot be loaded
    • isContentCache

      public boolean isContentCache()
      Specified by:
      isContentCache in interface org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
    • clearContentCache

      public void clearContentCache()
      Specified by:
      clearContentCache in interface org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
    • isContentCacheCleared

      public boolean isContentCacheCleared()
    • isAllowContextMapAll

      public boolean isAllowContextMapAll()
      Whether the context map is limited to only include the message body and headers
      Specified by:
      isAllowContextMapAll in interface org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
    • setAllowContextMapAll

      public void setAllowContextMapAll(boolean allowContextMapAll)
      Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API.
    • getCamelId

      public String getCamelId()
      Specified by:
      getCamelId in interface org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
    • getCamelManagementName

      public String getCamelManagementName()
      Specified by:
      getCamelManagementName in interface org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
    • getState

      public String getState()
      Specified by:
      getState in interface org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
    • setContentCache

      public void setContentCache(boolean contentCache)
      Sets whether to use resource content cache or not.
      Specified by:
      setContentCache in interface org.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
    • getResourceUri

      public String getResourceUri()
    • setResourceUri

      public void setResourceUri(String resourceUri)
      Path to the resource.

      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