|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.ehcache.annotations.key.AbstractCacheKeyGenerator<T>
public abstract class AbstractCacheKeyGenerator<T extends java.io.Serializable>
Base class for cache key generators. Handles common logic for including/excluding the method
signature from key generation. Also provides support for avoiding circular references for key
generators that traverse the argument object graph via the register(Object) and
unregister(Object) APIs
| Constructor Summary | |
|---|---|
AbstractCacheKeyGenerator()
Default constructor, same as calling AbstractCacheKeyGenerator(boolean, boolean) with (true, true) |
|
AbstractCacheKeyGenerator(boolean includeMethod,
boolean includeParameterTypes)
|
|
| Method Summary | |
|---|---|
T |
generateKey(org.aopalliance.intercept.MethodInvocation methodInvocation)
Generates the key for a cache entry. |
abstract T |
generateKey(java.lang.Object... data)
Called to generate the key. |
boolean |
isCheckforCycles()
|
boolean |
isIncludeMethod()
|
boolean |
isIncludeParameterTypes()
|
protected boolean |
register(java.lang.Object element)
Registers the given object. |
void |
setCheckforCycles(boolean checkforCycles)
If the key generation should gracefully handle object graph cycles. |
void |
setIncludeMethod(boolean includeMethod)
Determines if the invoked method signature should be included in the generated cache key. |
void |
setIncludeParameterTypes(boolean includeParameterTypes)
Determines if the method parameter types returned by Method.getParameterTypes() should be
included in the generated key. |
protected void |
unregister(java.lang.Object element)
Unregisters the given object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractCacheKeyGenerator()
AbstractCacheKeyGenerator(boolean, boolean) with (true, true)
public AbstractCacheKeyGenerator(boolean includeMethod,
boolean includeParameterTypes)
setIncludeMethod(boolean),
setIncludeParameterTypes(boolean)| Method Detail |
|---|
public final boolean isIncludeMethod()
public final void setIncludeMethod(boolean includeMethod)
Method.getDeclaringClass(), Method.getName(), and Method.getReturnType()
are included in the object array the key is generated from. Note that the effect of this option is
such that two methods with the same arguments will have different keys if true. If you have two methods
in the same class with the same name and return value you may want to enable setIncludeParameterTypes(boolean)
for even more specific key generation.
Note that including the method signature in key generation reduces key generation speed.
includeMethod - true If the Method from the MethodInvocation should be
included in the generated key, defaults to true.setIncludeParameterTypes(boolean)public final boolean isIncludeParameterTypes()
public final void setIncludeParameterTypes(boolean includeParameterTypes)
Method.getParameterTypes() should be
included in the generated key. This is broken out into a separate option because the call results
in a clone() call on the Class[] every time Method.getParameterTypes() which reduces key
generation speed.
This is option is only used if setIncludeMethod(boolean) is true.
includeParameterTypes - true if the Method.getParameterTypes() should be included in
the generated key, defaults to false.setIncludeMethod(boolean)public final boolean isCheckforCycles()
public final void setCheckforCycles(boolean checkforCycles)
register(Object) and
unregister(Object) methods are non-functional. If true the implementation of this class must correctly
utilize the register(Object) and unregister(Object) methods to track visited objects.
checkforCycles - Defaults to false.public T generateKey(org.aopalliance.intercept.MethodInvocation methodInvocation)
CacheKeyGenerator
generateKey in interface CacheKeyGenerator<T extends java.io.Serializable>methodInvocation - the description of an invocation to the intercepted method.
Serializableprotected final boolean register(java.lang.Object element)
Registers the given object. Used by the reflection methods to avoid infinite loops.
element - The object to register.
protected final void unregister(java.lang.Object element)
Unregisters the given object. Used by the reflection methods to avoid infinite loops.
public abstract T generateKey(java.lang.Object... data)
setIncludeMethod(boolean) and
setIncludeParameterTypes(boolean) the the appropriate parts of the Method
signature will be included in the data array.
generateKey in interface CacheKeyGenerator<T extends java.io.Serializable>data - the objects to use when generating the key
Serializable cache key for the method invocation.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||