javax.cache.annotation
Annotation Type CacheDefaults


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

Allows the configuration of defaults for CacheResult, CachePut, CacheRemoveEntry, and CacheRemoveAll at the class level. Without the method level annotations this annotation has no effect.

Example of specifying a default cache name that is used by the annotations on the getDomain and deleteDomain methods. The annotation for getAllDomains would use the "allDomains" cache name 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<Domain> getAllDomains() {
     ...
   }
 }
 

Since:
1.0
Author:
Rick Hightower

Optional Element Summary
 Class<? extends CacheKeyGenerator> cacheKeyGenerator
          (Optional) The CacheKeyGenerator to use to generate the CacheKey for interacting with the specified Cache.
 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)

Applicable for CacheResult, CachePut, CacheRemoveEntry, and CacheRemoveAll

 Class<? extends CacheResolverFactory> cacheResolverFactory
          (Optional) The CacheResolverFactory used to find the CacheResolver to use at runtime.
 

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)

Applicable for CacheResult, CachePut, CacheRemoveEntry, and CacheRemoveAll

Default:
""

cacheResolverFactory

public abstract Class<? extends CacheResolverFactory> cacheResolverFactory
(Optional) The CacheResolverFactory used to find the CacheResolver to use at runtime.

The default resolver pair will resolve the cache by name from the default CacheManager

Applicable for CacheResult, CachePut, CacheRemoveEntry, and CacheRemoveAll

Default:
javax.cache.annotation.CacheResolverFactory.class

cacheKeyGenerator

public abstract Class<? extends CacheKeyGenerator> cacheKeyGenerator
(Optional) The CacheKeyGenerator to use to generate the CacheKey for interacting with the specified Cache.

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

Applicable for CacheResult, CachePut, and CacheRemoveEntry

See Also:
CacheKeyParam
Default:
javax.cache.annotation.CacheKeyGenerator.class


Copyright © 2012. All Rights Reserved.