-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
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:
- ExtendedEhCacheFactoryBean.java (11.38 kB)
Issue Links:
- Add facility to EhCacheFactorybean for registering event listeners [SPR-6234] #10902 Add facility to EhCacheFactorybean for registering event listeners ("is duplicated by")