@Target(value={METHOD,TYPE}) @Retention(value=RUNTIME) public @interface CacheRemoveEntry
CacheRemoveEntry
is invoked a GeneratedCacheKey
will be generated and
Cache.remove(Object)
will be invoked on the specified cache.
The default behavior is to call Cache.remove(Object)
after the annotated method is invoked,
this behavior can be changed by setting afterInvocation()
to false in which case Cache.remove(Object)
will be called before the annotated method is invoked.
Example of removing a specific Domain object from the "domainCache". A GeneratedCacheKey
will be generated
from the String and int parameters and used to call Cache.remove(Object)
after
the deleteDomain method completes successfully.
Exception Handling, only used ifpackage my.app; public class DomainDao { @CacheRemoveEntry(cacheName="domainCache") public void deleteDomain(String domainId, int index) { ... } }
afterInvocation()
is true.
evictFor()
and noEvictFor()
are both empty then all exceptions prevent the removeevictFor()
is specified and noEvictFor()
is not specified then only exceptions
which pass an instanceof check against the evictFor list result in a removenoEvictFor()
is specified and evictFor()
is not specified then all exceptions
which do not pass an instanceof check against the noEvictFor result in a removeevictFor()
and noEvictFor()
are both specified then exceptions which pass an
instanceof check against the evictFor list but do not pass an instanceof check against the noEvictFor
list result in a removeCacheKey
Modifier and Type | Optional Element and Description |
---|---|
boolean |
afterInvocation
When
Cache.remove(Object) should be called. |
Class<? extends CacheKeyGenerator> |
cacheKeyGenerator
The
CacheKeyGenerator to use to generate the GeneratedCacheKey for interacting
with the specified Cache. |
String |
cacheName
The name of the cache.
|
Class<? extends CacheResolverFactory> |
cacheResolverFactory
The
CacheResolverFactory used to find the CacheResolver to use at runtime. |
Class<? extends Throwable>[] |
evictFor
|
Class<? extends Throwable>[] |
noEvictFor
|
public abstract String cacheName
CacheDefaults.cacheName()
, if that is not set it
a CacheAnnotationConfigurationException
will be thrown by the provider.public abstract boolean afterInvocation
Cache.remove(Object)
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 put will not be executed.public abstract Class<? extends CacheResolverFactory> cacheResolverFactory
CacheResolverFactory
used to find the CacheResolver
to use at runtime.
The default resolver pair will resolve the cache by name from the default CacheManager
public abstract Class<? extends CacheKeyGenerator> cacheKeyGenerator
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()
CacheKey
public abstract Class<? extends Throwable>[] evictFor
classes
, which must be a
subclass of Throwable
, indicating which exception types must cause
a cache evict. Only used if afterInvocation()
is true.public abstract Class<? extends Throwable>[] noEvictFor
Classes
, which must be a
subclass of Throwable
, indicating which exception types must not
cause a cache evict. Only used if afterInvocation()
is true.Copyright © 2013. All Rights Reserved.