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 invokingCache
operations and using a configurableCacheErrorHandler
when an exception occurs.- Since:
- 4.1
- Author:
- Stephane Nicoll
- See Also:
CacheErrorHandler
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCacheInvoker()
protected
AbstractCacheInvoker(CacheErrorHandler errorHandler)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doClear(Cache cache)
ExecuteCache.clear()
on the specifiedCache
and invoke the error handler if an exception occurs.protected void
doEvict(Cache cache, Object key)
ExecuteCache.evict(Object)
on the specifiedCache
and invoke the error handler if an exception occurs.protected Cache.ValueWrapper
doGet(Cache cache, Object key)
ExecuteCache.get(Object)
on the specifiedCache
and invoke the error handler if an exception occurs.protected void
doPut(Cache cache, Object key, Object result)
ExecuteCache.put(Object, Object)
on the specifiedCache
and invoke the error handler if an exception occurs.CacheErrorHandler
getErrorHandler()
Return theCacheErrorHandler
to use.void
setErrorHandler(CacheErrorHandler errorHandler)
Set theCacheErrorHandler
instance 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 theCacheErrorHandler
instance to use to handle errors thrown by the cache provider. By default, aSimpleCacheErrorHandler
is used who throws any exception as is.
getErrorHandler
public CacheErrorHandler getErrorHandler()
Return theCacheErrorHandler
to use.
doGet
protected Cache.ValueWrapper doGet(Cache cache, Object key)
ExecuteCache.get(Object)
on the specifiedCache
and invoke the error handler if an exception occurs. Returnnull
if 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 specifiedCache
and invoke the error handler if an exception occurs.
doEvict
protected void doEvict(Cache cache, Object key)
ExecuteCache.evict(Object)
on the specifiedCache
and invoke the error handler if an exception occurs.
doClear
protected void doClear(Cache cache)
ExecuteCache.clear()
on the specifiedCache
and invoke the error handler if an exception occurs.