Annotation Type CacheRemoveAll


  • @Target({METHOD,TYPE})
    @Retention(RUNTIME)
    public @interface CacheRemoveAll
    When a method annotated with CacheRemoveAll is invoked all elements in the specified cache will be removed via the Cache.removeAll() method

    The default behavior is to call Cache.removeAll() after the annotated method is invoked, this behavior can be changed by setting afterInvocation() to false in which case Cache.removeAll() will be called before the annotated method is invoked.

    Example of removing all Domain objects from the "domainCache". Cache.removeAll() will be called after deleteAllDomains() returns successfully.

    
     package my.app;
     
     public class DomainDao {
       @CacheRemoveAll(cacheName="domainCache")
       public void deleteAllDomains() {
         ...
       }
     }
     

    Exception Handling, only used if afterInvocation() is true.

    1. If evictFor() and noEvictFor() are both empty then all exceptions prevent the removeAll
    2. If evictFor() is specified and noEvictFor() is not specified then only exceptions that pass an instanceof check against the evictFor list result in a removeAll
    3. If noEvictFor() is specified and evictFor() is not specified then all exceptions that do not pass an instanceof check against the noEvictFor result in a removeAll
    4. If evictFor() and noEvictFor() are both specified then exceptions that pass an instanceof check against the evictFor list but do not pass an instanceof check against the noEvictFor list result in a removeAll
    Since:
    1.0
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean afterInvocation
      When Cache.removeAll() should be called.
      java.lang.String cacheName
      /** The name of the cache.
      java.lang.Class<? extends CacheResolverFactory> cacheResolverFactory
      The CacheResolverFactory used to find the CacheResolver to use at runtime.
      java.lang.Class<? extends java.lang.Throwable>[] evictFor
      Defines zero (0) or more exception classes, that must be a subclass of Throwable, indicating the exception types that must cause a cache eviction.
      java.lang.Class<? extends java.lang.Throwable>[] noEvictFor
      Defines zero (0) or more exception Classes, that must be a subclass of Throwable, indicating the exception types that must not cause a cache eviction.
    • Element Detail

      • cacheName

        java.lang.String cacheName
        /** The name of the cache.

        If not specified defaults first to CacheDefaults.cacheName() and if that is not set it defaults to: package.name.ClassName.methodName(package.ParameterType,package.ParameterType)

        Default:
        ""
      • afterInvocation

        boolean afterInvocation
        When Cache.removeAll() should be called. If true it is called after the annotated method invocation completes successfully. If false it is called before the annotated method is invoked.

        Defaults to true.

        If true and the annotated method throws an exception the removeAll will not be executed.

        Default:
        true
      • evictFor

        java.lang.Class<? extends java.lang.Throwable>[] evictFor
        Defines zero (0) or more exception classes, that must be a subclass of Throwable, indicating the exception types that must cause a cache eviction. Only used if afterInvocation() is true.
        Default:
        {}
      • noEvictFor

        java.lang.Class<? extends java.lang.Throwable>[] noEvictFor
        Defines zero (0) or more exception Classes, that must be a subclass of Throwable, indicating the exception types that must not cause a cache eviction. Only used if afterInvocation() is true.
        Default:
        {}