Solution:
This is how we solved this issue:
- We copied all the cache configuration from
ABCehCache.xml
(from ABC jar) toXYZehCache.xml
(from XYZ war). - We deleted the
ABCehCache.xml
(from ABC jar) but all the configuration(like bean instantiation forehCache.xml
and Spring AOP) insideABC-spring.xml
will remain same. - In
XYZ-spring.xml
, We importedABC-spring.xml
and defined composite cache manager.
Supported Configuration files:
ABC-spring.xml:
<aop:aspectj-autoproxy proxy-target-class="true" />
<bean id="CacheManager1" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache"></property>
</bean>
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:config-location="classpath:ABCEhcache.xml" />
XYZ-spring.xml:
<import resource="classpath*:ABC-spring.xml" />
<aop:aspectj-autoproxy proxy-target-class="true" />
<bean id="cacheManager" class="org.springframework.cache.support.CompositeCacheManager">
<property name="cacheManagers">
<array>
<ref bean="CacheManager1" />
<ref bean="CacheManager2" />
</array>
</property>
<property name="fallbackToNoOpCache" value="true" />
</bean>
<bean id="CacheManager2" class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cache-manager-ref="ehcache" />
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:config-location="classpath:XYZEhcache.xml" />
Hope this will help!!