Top Description Interfaces Annotations
[default module]

Package javax.cache.annotation


The annotations in this package provide method interceptors for user supplied classes.

In the case of a the javax.cache.annotation.CacheResult annotation, if the cache can satisfy the request a result is returned by the method from cache, not from method execution. For the mutative annotations such as javax.cache.annotation.CacheResult the annotation allows the cached value to be mutated so that it will be correct the next time javax.cache.annotation.CacheResult is used.

Any operations against a cache via an annotation will have the same behaviour as if the javax.cache.annotation.CacheResult methods were used. So if the same underlying cache is used for an annotation and a direct API call, the same data would be returned. Annotations therefore provide an additional API for interacting with caches.

To use these annotations you'll need a library or framework that processes these annotations and intercepts calls to your application objects to provide the caching behaviour. This would commonly be provided by a dependency injection framework such as defined by CDI in Java EE.

Authors
Eric Dalquist, Greg Luck
Since
1.0

Interface Summary

Modifier and TypeInterface and Description
public interface
CacheInvocationContext<
The type of annotation this context information is for. One of CacheResult, CachePut, CacheRemove, or CacheRemoveAll.
A extends Annotation
>

Runtime information about an intercepted method invocation for a method annotated with CacheResult, CachePut, CacheRemove, or CacheRemoveAll

Used with CacheResolver#resolveCache(CacheInvocationContext) to determine the javax.cache.Cache to use at runtime for the method invocation.

public interface
CacheInvocationParameter

A parameter to an intercepted method invocation.

public interface
public interface
CacheKeyInvocationContext<
The type of annotation this context information is for. One of CacheResult, CachePut, or CacheRemove.
A extends Annotation
>

Runtime information about an intercepted method invocation for a method annotated with CacheResult, CachePut, or CacheRemove.

public interface
CacheMethodDetails<
The type of annotation this context information is for. One of CacheResult, CachePut, CacheRemove, or CacheRemoveAll.
A extends Annotation
>

Static information about a method annotated with one of: CacheResult, CachePut, CacheRemove, or CacheRemoveAll

Used with CacheResolverFactory#getCacheResolver(CacheMethodDetails) to determine the CacheResolver to use with the method.

public interface
CacheResolver

Determines the Cache to use for an intercepted method invocation.

public interface
CacheResolverFactory

Determines the CacheResolver to use for an annotated method.

public interface
GeneratedCacheKey

A Serializable, immutable, thread-safe object that is used as a key, automatically generated by a CacheKeyGenerator.

Annotation Summary

Modifier and TypeAnnotation and Description
public @interface
CacheDefaults

Allows the configuration of defaults for CacheResult, CachePut, CacheRemove, and CacheRemoveAll at the class level.

public @interface
CacheKey

Marks a method argument as part of the cache key.

public @interface
CachePut

When a method annotated with CachePut is invoked a GeneratedCacheKey will be generated and Cache#put(Object, Object) will be invoked on the specified cache storing the value marked with CacheValue.

public @interface
CacheRemove

When a method annotated with CacheRemove is invoked a GeneratedCacheKey will be generated and Cache#remove(Object) will be invoked on the specified cache.

public @interface
CacheRemoveAll

When a method annotated with CacheRemoveAll is invoked all elements in the specified cache will be removed via the Cache#removeAll() method

The default behavior is to call Cache#removeAll() after the annotated method is invoked, this behavior can be changed by setting afterInvocation() to false in which case Cache#removeAll() will be called before the annotated method is invoked.

public @interface
CacheResult

When a method annotated with CacheResult is invoked a GeneratedCacheKey will be generated and Cache#get(Object) is called before the annotated method actually executes.

public @interface
CacheValue

Marks the parameter to be cached for a method annotated with CachePut.