Class JCachePolicy
java.lang.Object
org.apache.camel.component.jcache.policy.JCachePolicy
- All Implemented Interfaces:
org.apache.camel.spi.Policy
Policy for routes. It caches the final body of a route and next time takes it from the cache instead of executing the
route. The cache key is determined by the keyExpression (message body by default). If there is an object in the cache
under that key the rest of the route is not executed, but the cached object is added to the Exchange.
Fields: cache: JCache to use cacheManager: If cache is not set, a new one is get or created using this cacheManager.
If cacheManager is not set, we try to lookup one from CamelContext. cacheName: Name of the cache to use or create.
RouteId is used by default. cacheConfiguration: CacheConfiguration used if a new cache is created. Using default
MutableConfiguration if not set. keyExpression: The Expression to generate the key for the cache. E.g
simple("${header.username}") enabled: If JCachePolicy is not enabled, no policy is added to the route. Has an impact
only during startup.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeWrap(org.apache.camel.Route route, org.apache.camel.NamedNode namedNode) org.apache.camel.Expressionjavax.cache.CachegetCache()javax.cache.configuration.Configurationjavax.cache.CacheManagerorg.apache.camel.ExpressionbooleanvoidsetBypassExpression(org.apache.camel.Expression bypassExpression) voidsetCache(javax.cache.Cache cache) voidsetCacheConfiguration(javax.cache.configuration.Configuration cacheConfiguration) voidsetCacheManager(javax.cache.CacheManager cacheManager) voidsetCacheName(String cacheName) voidsetEnabled(boolean enabled) voidsetKeyExpression(org.apache.camel.Expression keyExpression) toString()org.apache.camel.Processorwrap(org.apache.camel.Route route, org.apache.camel.Processor processor)
-
Constructor Details
-
JCachePolicy
public JCachePolicy()
-
-
Method Details
-
beforeWrap
public void beforeWrap(org.apache.camel.Route route, org.apache.camel.NamedNode namedNode) - Specified by:
beforeWrapin interfaceorg.apache.camel.spi.Policy
-
wrap
public org.apache.camel.Processor wrap(org.apache.camel.Route route, org.apache.camel.Processor processor) - Specified by:
wrapin interfaceorg.apache.camel.spi.Policy
-
getCache
public javax.cache.Cache getCache() -
setCache
public void setCache(javax.cache.Cache cache) -
getCacheManager
public javax.cache.CacheManager getCacheManager() -
setCacheManager
public void setCacheManager(javax.cache.CacheManager cacheManager) -
getCacheConfiguration
public javax.cache.configuration.Configuration getCacheConfiguration() -
setCacheConfiguration
public void setCacheConfiguration(javax.cache.configuration.Configuration cacheConfiguration) -
getCacheName
-
setCacheName
-
getKeyExpression
public org.apache.camel.Expression getKeyExpression() -
setKeyExpression
public void setKeyExpression(org.apache.camel.Expression keyExpression) -
getBypassExpression
public org.apache.camel.Expression getBypassExpression() -
setBypassExpression
public void setBypassExpression(org.apache.camel.Expression bypassExpression) -
isEnabled
public boolean isEnabled() -
setEnabled
public void setEnabled(boolean enabled) -
toString
-