EhCacheFactoryBean should support CacheEventListener [SPR-5641] #10312
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: duplicate
A duplicate of another issue
type: enhancement
A general enhancement
Dominique Jean-Prost opened SPR-5641 and commented
Actually, EhCacheFactoryBean doesn't allow instanciate EhCache caches with CacheEventListeners. This forbids for instance to instanciate caches that supports distribution over a cluster, because the way ehcache runs needs the cache to be fully setup before adding it to the CacheManager (see net.sf.ehcache.distribution.RMICacheManagerPeerListener.notifyCacheAdded(String)).
I wrote an extended version of EhCacheFactoryBean so that I can provide cacheEventListeners to the factory in order to have distribution works.
Now I think you can backport my class to spring-core so that evereybody can use it. As I can't find the url of spring scm, I can't provide patch, although I wish I could.
Here is what you have to setup in your bean definition :
<bean id="eventListenersFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
scope="singleton" />
<bean class="com.dexia.sofaxis.common.cache.ExtendedEhCacheFactoryBean">
<property name="diskPersistent">
<value>false</value>
</property>
<property name="cacheName">
<value>itemsReferenceData</value>
</property>
<property name="cacheManager">
<ref bean="globalCacheManager" />
</property>
<property name="eternal">
<value>true</value>
</property>
<property name="maxElementsInMemory">
<value>10000</value>
</property>
<property name="overflowToDisk">
<value>true</value>
</property>
<property name="cacheEventListeners">
<list>
<bean factory-bean="eventListenersFactory" factory-method="createCacheEventListener">
<constructor-arg>
<null />
</constructor-arg>
</bean>
</list>
</property>
</bean>
Affects: 2.5.1
Attachments:
Issue Links:
The text was updated successfully, but these errors were encountered: