public class TransactionAwareCacheManagerProxy extends Object implements CacheManager, InitializingBean
CacheManager
, exposing transaction-aware Cache
objects
which synchronize their Cache.put(java.lang.Object, java.lang.Object)
operations with Spring-managed transactions
(through Spring's TransactionSynchronizationManager
,
performing the actual cache put operation only in the after-commit phase of a successful transaction.
If no transaction is active, Cache.put(java.lang.Object, java.lang.Object)
operations will be performed immediately, as usual.setTargetCacheManager(org.springframework.cache.CacheManager)
,
TransactionAwareCacheDecorator
,
TransactionSynchronizationManager
Constructor and Description |
---|
TransactionAwareCacheManagerProxy()
Create a new TransactionAwareCacheManagerProxy, setting the target CacheManager
through the
setTargetCacheManager(org.springframework.cache.CacheManager) bean property. |
TransactionAwareCacheManagerProxy(CacheManager targetCacheManager)
Create a new TransactionAwareCacheManagerProxy for the given target CacheManager.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
Cache |
getCache(String name)
Return the cache associated with the given name.
|
Collection<String> |
getCacheNames()
Return a collection of the cache names known by this manager.
|
void |
setTargetCacheManager(CacheManager targetCacheManager)
Set the target CacheManager to proxy.
|
public TransactionAwareCacheManagerProxy()
setTargetCacheManager(org.springframework.cache.CacheManager)
bean property.public TransactionAwareCacheManagerProxy(CacheManager targetCacheManager)
targetCacheManager
- the target CacheManager to proxypublic void setTargetCacheManager(CacheManager targetCacheManager)
public void afterPropertiesSet()
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
public Cache getCache(String name)
CacheManager
getCache
in interface CacheManager
name
- the cache identifier (must not be null
)null
if none foundpublic Collection<String> getCacheNames()
CacheManager
getCacheNames
in interface CacheManager