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, lock, 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 TypeMethodDescriptionvoidGets the resource as an input stream considering the cache flag as well.protected InputStreamgetState()booleanbooleanbooleanprotected InputStreamloadResource(String uri) Loads the given resource.voidsetAllowContextMapAll(boolean allowContextMapAll) Sets whether the context map should allow access to all details.voidsetContentCache(boolean contentCache) Sets whether to use resource content cache or not.voidsetResourceUri(String resourceUri) Path to the resource.Methods inherited from class org.apache.camel.support.ProcessorEndpoint
createPollingConsumer, createProcessor, createProducer, getProcessor, onExchange, setProcessorMethods inherited from class org.apache.camel.support.DefaultPollingEndpoint
createConsumerMethods 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, setUseFixedDelayMethods 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, toStringMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doStart, doStop, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.ComponentAware
getComponentMethods inherited from interface org.apache.camel.Endpoint
getEndpointBaseUri, isSingletonProducerMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods 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
@ManagedAttribute(description="Whether the resource is cached") public boolean isContentCache()- Specified by:
isContentCachein interfaceorg.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
-
clearContentCache
@ManagedOperation(description="Clears the cached resource, forcing to re-load the resource on next request") public void clearContentCache()- Specified by:
clearContentCachein interfaceorg.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
-
isContentCacheCleared
public boolean isContentCacheCleared() -
isAllowContextMapAll
@ManagedAttribute(description="Whether the context map is limited to only include the message body and headers") public boolean isAllowContextMapAll() -
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:
getCamelIdin interfaceorg.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
-
getCamelManagementName
- Specified by:
getCamelManagementNamein interfaceorg.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
-
getState
- Specified by:
getStatein interfaceorg.apache.camel.api.management.mbean.ManagedResourceEndpointMBean
-
setContentCache
public void setContentCache(boolean contentCache) Sets whether to use resource content cache or not.- Specified by:
setContentCachein 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
-