Class EhcacheJCacheCacheManager
java.lang.Object
org.springframework.cache.support.AbstractCacheManager
org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager
org.springframework.cache.jcache.JCacheCacheManager
com.broadleafcommerce.common.extension.cache.ehcache.EhcacheJCacheCacheManager
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean,org.springframework.cache.CacheManager
public class EhcacheJCacheCacheManager
extends org.springframework.cache.jcache.JCacheCacheManager
Implementation of a CacheManager that integrates Ehcache and JCache operations and provides
enhanced capabilities for deep cloning of cache values using a
Cloner.
This class extends JCacheCacheManager and overrides certain behaviors to wrap
JCacheCache with an EhcacheProxy that leverages a Cloner instance for
deep cloning of cached objects. This ensures that cached data returned by the cache is not
modified externally and maintains data integrity.
-
Constructor Summary
ConstructorsConstructorDescriptionEhcacheJCacheCacheManager(javax.cache.CacheManager cacheManager, Cloner cloner) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.cache.CachedecorateCache(org.springframework.cache.Cache cache) Overrides the default decoration logic to wrapJCacheCacheinstances with anEhcacheProxy.Methods inherited from class org.springframework.cache.jcache.JCacheCacheManager
afterPropertiesSet, getCacheManager, getMissingCache, isAllowNullValues, loadCaches, setAllowNullValues, setCacheManagerMethods inherited from class org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager
isTransactionAware, setTransactionAwareMethods inherited from class org.springframework.cache.support.AbstractCacheManager
getCache, getCacheNames, initializeCaches, lookupCache
-
Constructor Details
-
EhcacheJCacheCacheManager
-
-
Method Details
-
decorateCache
@NonNull protected org.springframework.cache.Cache decorateCache(@NonNull org.springframework.cache.Cache cache) Overrides the default decoration logic to wrapJCacheCacheinstances with anEhcacheProxy.By using
decorateCacheinstead of overridinggetCache, we ensure that the proxying logic is applied only once when the cache is first initialized or added to the manager. This provides several benefits:- Performance: Avoids the overhead of creating new proxy and wrapper objects on every cache access.
- Reference Equality: Ensures that subsequent calls to
getCachereturn the same stable instance, which is critical for synchronization and metadata tracking. - Architectural Consistency: Leverages the superclass's built-in instance management and mapping.
- Overrides:
decorateCachein classorg.springframework.cache.transaction.AbstractTransactionSupportingCacheManager- Parameters:
cache- the original cache instance to decorate- Returns:
- the decorated cache, wrapped in an
EhcacheProxyif it is aJCacheCache
-