multiple ehcache.xml in .war
Instead of replacing ehcache.xml during packing time, i keep the standalone and clustered ehcache configuration in the classpath and let a configuration property decide which to use:
in Config.groovy:
if (System.getProperty("clustered", "false") == "true") {
hibernate.config.location = ["classpath:hibernate.cluster.cfg.xml"]
}
This adds an additional hibernate config file in case of a clustered setting.
The file hibernate.cluster.cfg.xml in grails-app/conf/hibernate looks like this:
<!DOCTYPE hibernate-configuration SYSTEM
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="net.sf.ehcache.configurationResourceName">/ehcache_distributed.xml</property>
</session-factory>
</hibernate-configuration>
This works, because EhCache is using the configuration property "net.sf.ehcache.configurationResourceName" if set to read its configuration from this URL instead of using classpath:ehcache.xml
This works with Grails 1.3.x (probably with newer Grails versions as well, but not yet tested it).
|