<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=djeanprost" rel="nofollow">Dominique Jean-Prost</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-5641?redirect=false" rel="nofollow">SPR-5641</a></strong> and commented</p>
<p dir="auto">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)).</p>
<p dir="auto">I wrote an extended version of EhCacheFactoryBean so that I can provide cacheEventListeners to the factory in order to have distribution works.<br>
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.</p>
<p dir="auto">Here is what you have to setup in your bean definition :<br>
&lt;bean id="eventListenersFactory" class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"<br>
scope="singleton" /&gt;</p>
<p dir="auto">&lt;bean class="com.dexia.sofaxis.common.cache.ExtendedEhCacheFactoryBean"&gt;<br>
&lt;property name="diskPersistent"&gt;<br>
&lt;value&gt;false&lt;/value&gt;<br>
&lt;/property&gt;<br>
&lt;property name="cacheName"&gt;<br>
&lt;value&gt;itemsReferenceData&lt;/value&gt;<br>
&lt;/property&gt;<br>
&lt;property name="cacheManager"&gt;<br>
&lt;ref bean="globalCacheManager" /&gt;<br>
&lt;/property&gt;<br>
&lt;property name="eternal"&gt;<br>
&lt;value&gt;true&lt;/value&gt;<br>
&lt;/property&gt;<br>
&lt;property name="maxElementsInMemory"&gt;<br>
&lt;value&gt;10000&lt;/value&gt;<br>
&lt;/property&gt;<br>
&lt;property name="overflowToDisk"&gt;<br>
&lt;value&gt;true&lt;/value&gt;<br>
&lt;/property&gt;<br>
&lt;property name="cacheEventListeners"&gt;<br>
&lt;list&gt;<br>
&lt;bean factory-bean="eventListenersFactory" factory-method="createCacheEventListener"&gt;<br>
&lt;constructor-arg&gt;<br>
&lt;null /&gt;<br>
&lt;/constructor-arg&gt;<br>
&lt;/bean&gt;<br>
&lt;/list&gt;<br>
&lt;/property&gt;<br>
&lt;/bean&gt;</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/15277/ExtendedEhCacheFactoryBean.java" rel="nofollow">ExtendedEhCacheFactoryBean.java</a> (<em>11.38 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398098389" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10902" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10902/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10902">#10902</a> Add facility to EhCacheFactorybean for registering event listeners (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=timster" rel="nofollow">Tim Kettering</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-361?redirect=false" rel="nofollow">SPR-361</a></strong> and commented</p>
<p dir="auto">This improvement is filed upon Colin's request in the forums.</p>
<p dir="auto"><a href="http://forum.springframework.org/viewtopic.php?t=1058" rel="nofollow">http://forum.springframework.org/viewtopic.php?t=1058</a></p>
<p dir="auto">here is a paste of my original forum post:</p>
<p dir="auto">I noticed that Spring is able to obtain the database vendor info from the datasource for it's SQLException handling.</p>
<p dir="auto">I looked around in the SQLErrorCodesFactory and I see that it calls JdbcUtils to extract the database meta data with a internal implementation of DatabaseMetaDataCallback.</p>
<p dir="auto">I was looking to use this kind of functionality in my code, and I was wondering if I was missing someting. Is there a method I can call to obtain the database metadata, or do I need to re-implement the code used in the SQLErrorCodesFactory?</p>
<p dir="auto">I would imagine that this could be a useful feature to have in the jdbc package. (obtaining database information from the datasource)</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.1 final</p>