Package org.apache.camel.component
Class ResourceEndpoint
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
- 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 Summary
FieldsFields 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
ConstructorsConstructorDescriptionResourceEndpoint
(String endpointUri, org.apache.camel.Component component, String resourceUri) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Gets the resource as an input stream considering the cache flag as well.protected InputStream
getState()
boolean
Whether the context map is limited to only include the message body and headersboolean
boolean
protected InputStream
loadResource
(String uri) Loads the given resource.void
setAllowContextMapAll
(boolean allowContextMapAll) Sets whether the context map should allow access to all details.void
setContentCache
(boolean contentCache) Sets whether to use resource content cache or not.void
setResourceUri
(String resourceUri) Path to the resource.Methods inherited from class org.apache.camel.support.ProcessorEndpoint
createPollingConsumer, createProcessor, createProducer, getProcessor, onExchange, 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, doInit, 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, 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, isRemote, 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
-
Field Details
-
log
protected final org.slf4j.Logger log
-
-
Constructor Details
-
ResourceEndpoint
public ResourceEndpoint() -
ResourceEndpoint
-
-
Method Details
-
getResourceAsInputStream
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
- Throws:
IOException
-
loadResource
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 interfaceorg.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
-
clearContentCache
public void clearContentCache()- Specified by:
clearContentCache
in interfaceorg.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 interfaceorg.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
- Specified by:
getCamelId
in interfaceorg.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
-
getCamelManagementName
- Specified by:
getCamelManagementName
in interfaceorg.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
-
getState
- Specified by:
getState
in interfaceorg.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 interfaceorg.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
-
getResourceUri
-
setResourceUri
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
-