Class AbstractCacheResultInterceptor

java.lang.Object
org.infinispan.jcache.annotation.AbstractCacheResultInterceptor
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CacheResultInterceptor, InjectedCacheResultInterceptor

public abstract class AbstractCacheResultInterceptor extends Object implements Serializable

CacheResult interceptor implementation. This interceptor uses the following algorithm describes in JSR-107.

When a method annotated with CacheResult is invoked the following must occur.

  1. Generate a key based on InvocationContext using the specified CacheKeyGenerator.
  2. Use this key to look up the entry in the cache.
  3. If an entry is found return it as the result and do not call the annotated method.
  4. If no entry is found invoke the method.
  5. Use the result to populate the cache with this key/result pair.
There is a skipGet attribute which if set to true will cause the method body to always be invoked and the return value put into the cache. The cache is not checked for the key before method body invocation, skipping steps 2 and 3 from the list above. This can be used for annotating methods that do a cache.put() with no other consequences.

Author:
Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI, Galder ZamarreƱo
See Also:
  • Constructor Details

    • AbstractCacheResultInterceptor

      public AbstractCacheResultInterceptor(javax.cache.annotation.CacheResolver defaultCacheResolver, CacheKeyInvocationContextFactory contextFactory)
  • Method Details

    • cacheResult

      public Object cacheResult(javax.interceptor.InvocationContext invocationContext) throws Throwable
      Throws:
      Throwable
    • getLog

      protected abstract org.infinispan.jcache.logging.Log getLog()