org.apache.camel.component
Class ResourceEndpoint

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.DefaultEndpoint
          extended by org.apache.camel.impl.ScheduledPollEndpoint
              extended by org.apache.camel.impl.DefaultPollingEndpoint
                  extended by org.apache.camel.impl.ProcessorEndpoint
                      extended by org.apache.camel.component.ResourceEndpoint
All Implemented Interfaces:
ManagedResourceEndpointMBean, CamelContextAware, Endpoint, IsSingleton, Service, ShutdownableService, HasId, StatefulService, SuspendableService
Direct Known Subclasses:
LanguageEndpoint

@ManagedResource(description="Managed ResourceEndpoint")
public abstract class ResourceEndpoint
extends ProcessorEndpoint
implements ManagedResourceEndpointMBean

A useful base class for endpoints which depend on a resource such as things like Velocity or XQuery based components.


Field Summary
protected  org.slf4j.Logger log
           
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
ResourceEndpoint()
           
ResourceEndpoint(String endpointUri, Component component, String resourceUri)
           
 
Method Summary
 void clearContentCache()
           
 InputStream getResourceAsInputStream()
          Gets the resource as an input stream considering the cache flag as well.
protected  InputStream getResourceAsInputStreamWithoutCache()
           
 String getResourceUri()
           
 boolean isContentCache()
           
 boolean isContentCacheCleared()
           
protected  InputStream loadResource(String uri)
          Loads the given resource.
 void setContentCache(boolean contentCache)
          Sets whether to use resource content cache or not - default is false.
 void setResourceUri(String resourceUri)
           
 
Methods inherited from class org.apache.camel.impl.ProcessorEndpoint
createPollingConsumer, createProcessor, createProducer, getProcessor, isSingleton, onExchange, setProcessor
 
Methods inherited from class org.apache.camel.impl.DefaultPollingEndpoint
createConsumer
 
Methods inherited from class org.apache.camel.impl.ScheduledPollEndpoint
configureProperties
 
Methods inherited from class org.apache.camel.impl.DefaultEndpoint
configureConsumer, createEndpointConfiguration, createEndpointUri, createExchange, createExchange, createExchange, doStart, doStop, equals, getCamelContext, getComponent, getConsumerProperties, getEndpointConfiguration, getEndpointKey, getEndpointUri, getExchangePattern, getId, hashCode, isLenientProperties, isSynchronous, setCamelContext, setConsumerProperties, setEndpointConfiguration, setEndpointUri, setEndpointUriIfNotSpecified, setExchangePattern, setSynchronous, toString
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, 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.Service
start, stop
 

Field Detail

log

protected final transient org.slf4j.Logger log
Constructor Detail

ResourceEndpoint

public ResourceEndpoint()

ResourceEndpoint

public ResourceEndpoint(String endpointUri,
                        Component component,
                        String resourceUri)
Method Detail

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

@ManagedAttribute(description="Whether the resource is cached")
public boolean isContentCache()
Specified by:
isContentCache in interface ManagedResourceEndpointMBean

clearContentCache

@ManagedOperation(description="Clears the cached resource, forcing to re-load the resource on next request")
public void clearContentCache()
Specified by:
clearContentCache in interface ManagedResourceEndpointMBean

isContentCacheCleared

public boolean isContentCacheCleared()

setContentCache

public void setContentCache(boolean contentCache)
Sets whether to use resource content cache or not - default is false.

Specified by:
setContentCache in interface ManagedResourceEndpointMBean
See Also:
getResourceAsInputStream()

getResourceUri

public String getResourceUri()

setResourceUri

public void setResourceUri(String resourceUri)


Apache CAMEL