javax.cache.annotation
Annotation Type CacheDefaults


@Target(value=TYPE)
@Retention(value=RUNTIME)
public @interface CacheDefaults

Allows the configuration of cacheName, cacheResolver and cacheKeyResolver at the class level. The same settings at the method level will override this. This allows you to have defaults at the class level.

Example of specifying a default cache name that is used by the getDomain and deleteDomain interceptors. The inteceptor for getAllDomains would use the "allDomains" cache specified in the method level annotation.

 package my.app;
 
 @CacheDefaults(cacheName="domainCache")
 public class DomainDao {
   @CacheResult
   public Domain getDomain(String domainId, int index) {
     ...
   }
   
   @CacheRemoveEntry
   public void deleteDomain(String domainId, int index) {
     ...
   }
   
   @CacheResult(cacheName="allDomains")
   public List getAllDomains() {
     ...
   }
 }
 

Since:
1.0
Author:
Rick Hightower

Optional Element Summary
 Class<? extends CacheKeyGenerator> cacheKeyGenerator
          (Optional) The CacheKeyGenerator to use to generate the cache key used when interacting with the Cache

Defaults to a key generator that uses Arrays.deepHashCode(Object[]) and Arrays.deepEquals(Object[], Object[]) with the array returned by CacheKeyInvocationContext.getKeyParameters()

 String cacheName
          (Optional) default name of the cache for the annotated class

If not specified defaults to: package.name.ClassName.methodName(package.ParameterType,package.ParameterType)

 Class<? extends CacheResolverFactory> cacheResolverFactory
          (Optional) The CacheResolverFactory to use to find the CacheResolver the intercepter will interact with.
 

cacheName

public abstract String cacheName
(Optional) default name of the cache for the annotated class

If not specified defaults to: package.name.ClassName.methodName(package.ParameterType,package.ParameterType)

Default:
""

cacheResolverFactory

public abstract Class<? extends CacheResolverFactory> cacheResolverFactory
(Optional) The CacheResolverFactory to use to find the CacheResolver the intercepter will interact with.

Defaults to resolving the cache by name from the default CacheManager

Default:
javax.cache.annotation.CacheResolverFactory.class

cacheKeyGenerator

public abstract Class<? extends CacheKeyGenerator> cacheKeyGenerator
(Optional) The CacheKeyGenerator to use to generate the cache key used when interacting with the Cache

Defaults to a key generator that uses Arrays.deepHashCode(Object[]) and Arrays.deepEquals(Object[], Object[]) with the array returned by CacheKeyInvocationContext.getKeyParameters()

Default:
javax.cache.annotation.CacheKeyGenerator.class


Copyright © 2011. All Rights Reserved.