Issue Details (XML | Word | Printable)

Key: SPR-4187
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Josh Devins
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring Framework

Add multiple config locations to EhCacheManagerFactoryBean to allow for deploy-time config overriding

Created: 28/Nov/07 07:46 PM   Updated: 14/May/08 06:08 PM
Component/s: SpringCORE
Affects Version/s: 2.5 final
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Java Source File EhCacheManagerFactoryBean.java (1 kB)
2. Java Source File EhCacheManagerFactoryBean2.java (5 kB)
3. XML File EhCacheManagerFactoryBean2.xml (0.5 kB)
4. Java Source File EhCacheManagerFactoryBeanTest.java (4 kB)
5. Java Source File EhCacheManagerFactoryBeanTest2.java (6 kB)



 Description  « Hide

Much like providing a list of properties files in priority for PropertyPlaceholderConfigurer, it would be nice to be able to do the same for EhCacheManagerFactoryBean. This would allow a default EhCache configuration to be inside your Jar/War on the classpath, and if need be, you can override that configuration by providing another location to load from.

Example XML:

<bean id="cacheManager"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocations">
<list>
<value>classpath*:ehcache.override.xml</value>
<value>classpath*:META-INF/ehcache.default.xml</value>
</list>
</property>
</bean>

Example code that should be added to EhCacheManagerFactoryBean (or in a subclass of it):

/**

  • Based on an array of configuration location {@link Resource}s listed in
    * order of decending priority, this will use the first available
    * {@link Resource} to configure the EhCache CacheManager.
  • @return the config location {@link Resource} to use
    */
    public void setConfigLocations(final Resource[] configLocations) {

if (configLocations == null || configLocations.length < 0) { logger.info("No valid configLocations were set."); return; }

// uses the first available config location
super.setConfigLocation(configLocations[0]);
}



Juergen Hoeller made changes - 29/Nov/07 08:02 AM
Field Original Value New Value
Assignee Juergen Hoeller [ juergen.hoeller ]
Josh Devins made changes - 29/Nov/07 01:30 PM
Attachment EhCacheManagerFactoryBean.java [ 13168 ]
Josh Devins made changes - 29/Nov/07 01:31 PM
Attachment EhCacheManagerFactoryBeanTest.java [ 13169 ]
Josh Devins made changes - 14/May/08 06:06 PM
Attachment EhCacheManagerFactoryBean2.java [ 14057 ]
Josh Devins made changes - 14/May/08 06:06 PM
Attachment EhCacheManagerFactoryBean2.xml [ 14058 ]
Josh Devins made changes - 14/May/08 06:06 PM