parent
71d70a6e06
commit
5c3ceb8ef0
|
|
@ -26,5 +26,5 @@ import java.lang.reflect.Method;
|
|||
*/
|
||||
public interface KeyGenerator<K> {
|
||||
|
||||
K extract(Method method, Object... params);
|
||||
K extract(Object target, Method method, Object... params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,6 +306,7 @@ public abstract class CacheAspectSupport implements InitializingBean {
|
|||
|
||||
private CacheDefinition definition;
|
||||
private final Collection<Cache<?, ?>> caches;
|
||||
private final Object target;
|
||||
private final Method method;
|
||||
private final Object[] args;
|
||||
|
||||
|
|
@ -318,6 +319,7 @@ public abstract class CacheAspectSupport implements InitializingBean {
|
|||
Object target, Class<?> targetClass) {
|
||||
this.definition = operationDefinition;
|
||||
this.caches = CacheAspectSupport.this.getCaches(definition);
|
||||
this.target = target;
|
||||
this.method = method;
|
||||
this.args = args;
|
||||
|
||||
|
|
@ -352,7 +354,7 @@ public abstract class CacheAspectSupport implements InitializingBean {
|
|||
return evaluator.key(definition.getKey(), method, evalContext);
|
||||
}
|
||||
|
||||
return keyGenerator.extract(method, args);
|
||||
return keyGenerator.extract(target, method, args);
|
||||
}
|
||||
|
||||
protected Collection<Cache<?, ?>> getCaches() {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import org.springframework.cache.KeyGenerator;
|
|||
*/
|
||||
public class DefaultKeyGenerator implements KeyGenerator<Object> {
|
||||
|
||||
public Object extract(Method method, Object... params) {
|
||||
public Object extract(Object target, Method method, Object... params) {
|
||||
if (params.length == 1) {
|
||||
return params[0];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue