Top Description Methods
javax.cache.annotation

public @Interface CacheDefaults

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
Imports
javax.cache.CacheManager, javax.enterprise.util.Nonbinding, java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target, java.util.Arrays

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

Following is an 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) {
    ...
  }

  @CacheRemove
  public void deleteDomain(String domainId, int index) {
    ...
  }

  @CacheResult(cacheName="allDomains")
  public List<Domain> getAllDomains() {
    ...
  }
}
Author
Rick Hightower
Since
1.0

Method Summary

Modifier and TypeMethod and Description
public Class<? extends CacheKeyGenerator>
cacheKeyGenerator()

The CacheKeyGenerator to use to generate the GeneratedCacheKey for interacting with the specified Cache.

public String
cacheName()

The 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, CacheRemove, and CacheRemoveAll

public Class<? extends CacheResolverFactory>
cacheResolverFactory()

The CacheResolverFactory used to find the CacheResolver to use at runtime.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

cacheKeyGeneratorback to summary
public Class<? extends CacheKeyGenerator> cacheKeyGenerator()

The CacheKeyGenerator to use to generate the GeneratedCacheKey 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 CacheRemove
Annotations
@Nonbinding
See Also
CacheKey
cacheNameback to summary
public String cacheName()

The 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, CacheRemove, and CacheRemoveAll

Annotations
@Nonbinding
cacheResolverFactoryback to summary
public Class<? extends CacheResolverFactory> cacheResolverFactory()

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, CacheRemove, and CacheRemoveAll

Annotations
@Nonbinding