Annotation Type CacheDefaults
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() {
...
}
}
- Since:
- 1.0
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass
<? extends CacheKeyGenerator> TheCacheKeyGenerator
to use to generate theGeneratedCacheKey
for interacting with the specified Cache.The default name of the cache for the annotated classClass
<? extends CacheResolverFactory> TheCacheResolverFactory
used to find theCacheResolver
to use at runtime.
-
Element Details
-
cacheName
String cacheNameThe default name of the cache for the annotated classIf not specified defaults to: package.name.ClassName.methodName(package.ParameterType,package.ParameterType)
Applicable for
CacheResult
,CachePut
,CacheRemove
, andCacheRemoveAll
- Default:
""
-
cacheResolverFactory
Class<? extends CacheResolverFactory> cacheResolverFactoryTheCacheResolverFactory
used to find theCacheResolver
to use at runtime.The default resolver pair will resolve the cache by name from the default
CacheManager
Applicable for
CacheResult
,CachePut
,CacheRemove
, andCacheRemoveAll
- Default:
javax.cache.annotation.CacheResolverFactory.class
-
cacheKeyGenerator
Class<? extends CacheKeyGenerator> cacheKeyGeneratorTheCacheKeyGenerator
to use to generate theGeneratedCacheKey
for interacting with the specified Cache.Defaults to a key generator that uses
Applicable forArrays.deepHashCode(Object[])
andArrays.deepEquals(Object[], Object[])
with the array returned byCacheKeyInvocationContext.getKeyParameters()
CacheResult
,CachePut
, andCacheRemove
- See Also:
- Default:
javax.cache.annotation.CacheKeyGenerator.class
-