Class JCachePolicy
- java.lang.Object
-
- org.apache.camel.component.jcache.policy.JCachePolicy
-
- All Implemented Interfaces:
org.apache.camel.spi.Policy
public class JCachePolicy extends Object implements 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 Constructor Description JCachePolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beforeWrap(org.apache.camel.Route route, org.apache.camel.NamedNode namedNode)
javax.cache.Cache
getCache()
javax.cache.configuration.Configuration
getCacheConfiguration()
javax.cache.CacheManager
getCacheManager()
String
getCacheName()
org.apache.camel.Expression
getKeyExpression()
boolean
isEnabled()
void
setCache(javax.cache.Cache cache)
void
setCacheConfiguration(javax.cache.configuration.Configuration cacheConfiguration)
void
setCacheManager(javax.cache.CacheManager cacheManager)
void
setCacheName(String cacheName)
void
setEnabled(boolean enabled)
void
setKeyExpression(org.apache.camel.Expression keyExpression)
String
toString()
org.apache.camel.Processor
wrap(org.apache.camel.Route route, org.apache.camel.Processor processor)
-
-
-
Method Detail
-
beforeWrap
public void beforeWrap(org.apache.camel.Route route, org.apache.camel.NamedNode namedNode)
- Specified by:
beforeWrap
in interfaceorg.apache.camel.spi.Policy
-
wrap
public org.apache.camel.Processor wrap(org.apache.camel.Route route, org.apache.camel.Processor processor)
- Specified by:
wrap
in 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
public String getCacheName()
-
setCacheName
public void setCacheName(String cacheName)
-
getKeyExpression
public org.apache.camel.Expression getKeyExpression()
-
setKeyExpression
public void setKeyExpression(org.apache.camel.Expression keyExpression)
-
isEnabled
public boolean isEnabled()
-
setEnabled
public void setEnabled(boolean enabled)
-
-