Class TransactionAwareCacheManagerProxy
java.lang.Object
org.springframework.cache.transaction.TransactionAwareCacheManagerProxy
- All Implemented Interfaces:
InitializingBean, CacheManager
public class TransactionAwareCacheManagerProxy
extends Object
implements CacheManager, InitializingBean
Proxy for a target
CacheManager, exposing transaction-aware Cache objects
which synchronize their Cache.put(Object, 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(Object, Object) operations will be performed immediately, as usual.- Since:
- 3.2
- Author:
- Juergen Hoeller
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new TransactionAwareCacheManagerProxy, setting the target CacheManager through thesetTargetCacheManager(CacheManager)bean property.TransactionAwareCacheManagerProxy(CacheManager targetCacheManager) Create a new TransactionAwareCacheManagerProxy for the given target CacheManager. -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.Get the cache associated with the given name.Get a collection of the cache names known by this manager.voidsetTargetCacheManager(CacheManager targetCacheManager) Set the target CacheManager to proxy.
-
Constructor Details
-
TransactionAwareCacheManagerProxy
public TransactionAwareCacheManagerProxy()Create a new TransactionAwareCacheManagerProxy, setting the target CacheManager through thesetTargetCacheManager(CacheManager)bean property. -
TransactionAwareCacheManagerProxy
Create a new TransactionAwareCacheManagerProxy for the given target CacheManager.- Parameters:
targetCacheManager- the target CacheManager to proxy
-
-
Method Details
-
setTargetCacheManager
Set the target CacheManager to proxy. -
afterPropertiesSet
public void afterPropertiesSet()Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
getCache
Description copied from interface:CacheManagerGet the cache associated with the given name.Note that the cache may be lazily created at runtime if the native provider supports it.
- Specified by:
getCachein interfaceCacheManager- Parameters:
name- the cache identifier (must not benull)- Returns:
- the associated cache, or
nullif such a cache does not exist or could be not created
-
getCacheNames
Description copied from interface:CacheManagerGet a collection of the cache names known by this manager.- Specified by:
getCacheNamesin interfaceCacheManager- Returns:
- the names of all caches known by the cache manager
-