public class TransactionAwareCacheManagerProxy extends java.lang.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 the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
Cache |
getCache(java.lang.String name)
Return the cache associated with the given name.
|
java.util.Collection<java.lang.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
BeanFactory
after it has set all bean properties
and satisfied BeanFactoryAware
, ApplicationContextAware
etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
afterPropertiesSet
in interface InitializingBean
public Cache getCache(java.lang.String name)
CacheManager
getCache
in interface CacheManager
name
- the cache identifier (must not be null
)null
if none foundpublic java.util.Collection<java.lang.String> getCacheNames()
CacheManager
getCacheNames
in interface CacheManager