Class 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 Detail

      • JCachePolicy

        public JCachePolicy()
    • Method Detail

      • beforeWrap

        public void beforeWrap​(org.apache.camel.Route route,
                               org.apache.camel.NamedNode namedNode)
        Specified by:
        beforeWrap in interface org.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 interface org.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)