Class AbstractCacheInvoker
- java.lang.Object
- org.springframework.cache.interceptor.AbstractCacheInvoker
- Direct Known Subclasses:
CacheAspectSupport,JCacheAspectSupport
public abstract class AbstractCacheInvoker extends Object
A base component for invokingCacheoperations and using a configurableCacheErrorHandlerwhen an exception occurs.- Since:
- 4.1
- Author:
- Stephane Nicoll
- See Also:
CacheErrorHandler
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCacheInvoker()protectedAbstractCacheInvoker(CacheErrorHandler errorHandler)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoClear(Cache cache)ExecuteCache.clear()on the specifiedCacheand invoke the error handler if an exception occurs.protected voiddoEvict(Cache cache, Object key)ExecuteCache.evict(Object)on the specifiedCacheand invoke the error handler if an exception occurs.protected Cache.ValueWrapperdoGet(Cache cache, Object key)ExecuteCache.get(Object)on the specifiedCacheand invoke the error handler if an exception occurs.protected voiddoPut(Cache cache, Object key, Object result)ExecuteCache.put(Object, Object)on the specifiedCacheand invoke the error handler if an exception occurs.CacheErrorHandlergetErrorHandler()Return theCacheErrorHandlerto use.voidsetErrorHandler(CacheErrorHandler errorHandler)Set theCacheErrorHandlerinstance to use to handle errors thrown by the cache provider.
Constructor Detail
AbstractCacheInvoker
protected AbstractCacheInvoker()
AbstractCacheInvoker
protected AbstractCacheInvoker(CacheErrorHandler errorHandler)
Method Detail
setErrorHandler
public void setErrorHandler(CacheErrorHandler errorHandler)
Set theCacheErrorHandlerinstance to use to handle errors thrown by the cache provider. By default, aSimpleCacheErrorHandleris used who throws any exception as is.
getErrorHandler
public CacheErrorHandler getErrorHandler()
Return theCacheErrorHandlerto use.
doGet
protected Cache.ValueWrapper doGet(Cache cache, Object key)
ExecuteCache.get(Object)on the specifiedCacheand invoke the error handler if an exception occurs. Returnnullif the handler does not throw any exception, which simulates a cache miss in case of error.- See Also:
Cache.get(Object)
doPut
protected void doPut(Cache cache, Object key, Object result)
ExecuteCache.put(Object, Object)on the specifiedCacheand invoke the error handler if an exception occurs.
doEvict
protected void doEvict(Cache cache, Object key)
ExecuteCache.evict(Object)on the specifiedCacheand invoke the error handler if an exception occurs.
doClear
protected void doClear(Cache cache)
ExecuteCache.clear()on the specifiedCacheand invoke the error handler if an exception occurs.