parent
dea1fc933f
commit
0eb40e1e5e
|
|
@ -21,7 +21,7 @@ import net.sf.ehcache.Element;
|
|||
import net.sf.ehcache.Status;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.interceptor.DefaultValue;
|
||||
import org.springframework.cache.interceptor.DefaultValueWrapper;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
|
@ -60,7 +60,7 @@ public class EhCacheCache implements Cache<Object, Object> {
|
|||
|
||||
public ValueWrapper<Object> get(Object key) {
|
||||
Element element = cache.get(key);
|
||||
return (element != null ? new DefaultValue<Object>(element.getObjectValue()) : null);
|
||||
return (element != null ? new DefaultValueWrapper<Object>(element.getObjectValue()) : null);
|
||||
}
|
||||
|
||||
public void put(Object key, Object value) {
|
||||
|
|
|
|||
|
|
@ -185,11 +185,11 @@ public abstract class CacheAspectSupport implements InitializingBean {
|
|||
|
||||
for (Iterator<Cache<?, ?>> iterator = caches.iterator(); iterator.hasNext() && !cacheHit;) {
|
||||
Cache cache = iterator.next();
|
||||
Cache.ValueWrapper<Object> value = cache.get(key);
|
||||
Cache.ValueWrapper<Object> wrapper = cache.get(key);
|
||||
|
||||
if (value != null) {
|
||||
if (wrapper != null) {
|
||||
cacheHit = true;
|
||||
retVal = value.get();
|
||||
retVal = wrapper.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,16 +199,16 @@ public abstract class CacheAspectSupport implements InitializingBean {
|
|||
+ method);
|
||||
}
|
||||
retVal = invocation.call();
|
||||
|
||||
// update all caches
|
||||
for (Cache cache : caches) {
|
||||
cache.put(key, retVal);
|
||||
}
|
||||
} else {
|
||||
if (log) {
|
||||
logger.trace("Key " + key + " found in cache, returning value " + retVal);
|
||||
}
|
||||
}
|
||||
|
||||
// update all caches
|
||||
for (Cache cache : caches) {
|
||||
cache.put(key, retVal);
|
||||
}
|
||||
}
|
||||
|
||||
if (cacheOp instanceof CacheEvictOperation) {
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ import org.springframework.cache.Cache.ValueWrapper;
|
|||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class DefaultValue<V> implements ValueWrapper<V> {
|
||||
public class DefaultValueWrapper<V> implements ValueWrapper<V> {
|
||||
|
||||
private final V value;
|
||||
|
||||
public DefaultValue(V value) {
|
||||
public DefaultValueWrapper(V value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.interceptor.DefaultValue;
|
||||
import org.springframework.cache.interceptor.DefaultValueWrapper;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
|
@ -76,7 +76,8 @@ public abstract class AbstractDelegatingCache<K, V> implements Cache<K, V> {
|
|||
}
|
||||
|
||||
public ValueWrapper<V> get(Object key) {
|
||||
return new DefaultValue<V>(filterNull(delegate.get(key)));
|
||||
V v = delegate.get(key);
|
||||
return (v != null ? new DefaultValueWrapper<V>(filterNull(v)) : null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
@ -85,8 +86,9 @@ public abstract class AbstractDelegatingCache<K, V> implements Cache<K, V> {
|
|||
Map map = delegate;
|
||||
map.put(key, NULL_HOLDER);
|
||||
}
|
||||
|
||||
delegate.put(key, value);
|
||||
else {
|
||||
delegate.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void evict(Object key) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<bean id="apc" class="org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator"/>
|
||||
|
||||
<bean id="annotationSource" class="org.springframework.cache.annotation.AnnotationCacheDefinitionSource"/>
|
||||
<bean id="annotationSource" class="org.springframework.cache.annotation.AnnotationCacheOperationSource"/>
|
||||
|
||||
<aop:config>
|
||||
<aop:advisor advice-ref="debugInterceptor" pointcut="execution(* *..CacheableService.*(..))" order="1"/>
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
<property name="cacheDefinitionSources" ref="annotationSource"/>
|
||||
</bean>
|
||||
|
||||
<bean id="advisor" class="org.springframework.cache.interceptor.BeanFactoryCacheDefinitionSourceAdvisor">
|
||||
<bean id="advisor" class="org.springframework.cache.interceptor.BeanFactoryCacheOperationSourceAdvisor">
|
||||
<property name="cacheDefinitionSource" ref="annotationSource"/>
|
||||
<property name="adviceBeanName" value="cacheInterceptor"/>
|
||||
</bean>
|
||||
|
|
|
|||
Loading…
Reference in New Issue