-
Jun 17th, 2011, 09:03 AM
#1
using cache annotations with many cacheManagers
We are integrating many modules into a single application. Each module defines its own spring config files and we are aggregating these config files into a single ApplicationContext.
Some modules have defined a CacheManager linked to a eh-cache config file, and use annotation-driven for proxying beans that need caching.
The problem we are facing in that although the cache-manager property is configurable, we must integrate many cache-managers, each one containing caches that are used by beans from different modules.
As an example, consider module 1, which defines a bean with methods annotated with @Cacheable. Its spring config file contains <cache:annotation-driven cache-manager="module1CacheManager"/>, and the definitino of a cacheManager, named "module1CacheManager", linked to the eh-cache config file named "eh-cache-module1.xml". This config files defines a cache named "usersCache", together with other global properties.
Another module (module 2) defines a bean that also uses cache with annotations. Thus it contains a spring config file with a cacheManager named "module2CacheManager" and <cache:annotation-driven cache-manager="module2CacheManager"/>. The CacheManager references a eh-cache config file with a cache named "countryCache".
We need to integrate both modules into a single application with a single Spring application context. When I create an application context with xml files from both modules, 2 cache managers are defined, but the second <cache:annotation-driven/> tag is ignored (and the 2nd cache manager too) as the cache-namespace parser only registers 1 cache aop advisor.
There should be a way to specify the cache-manager name to use on a class-level for classes that use @Cacheable annotations (with a default to "cacheManager"), and remove the cache-manager attribute from <cache:annotation-driven/>.
--
Gaëtan PITTELOUD
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules