[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
multiple ehcache.xml (e.g. for clustering) in grails webapp  XML
Forum Index -> Ehcache
Author Message
romanstu

neo

Joined: 09/06/2014 16:49:47
Messages: 1
Offline

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).
 
Forum Index -> Ehcache
Go to:   
Powered by JForum 2.1.7 © JForum Team