Hi,
I would like to make ehcache look for the config file ehcache.xml in a location that is not directly in the classpath but rather in a sub directory.
The only way I found to do that is to copy org.hibernate.cache.EhCacheProvider, change the start method to the following and config hibernate to use my implementation:
Code:
public void start(Properties properties) throws CacheException {
String configFileLocation = properties.getProperty(EHCACHE_CONFIG_FILE);
try {
if (configFileLocation != null){
URL configFileUrl = getClass().getClassLoader().getResource(configFileLocation);
manager = CacheManager.create(configFileUrl);
}else{
manager = CacheManager.create(); // default behavior
}
}
catch (net.sf.ehcache.CacheException e) {
throw new CacheException(e);
}
}
The reason I had to COPY instead of extending is that the manager member of org.hibernate.cache.EhCacheProvider is private and has no getter/setter.
Do you see any way to do it more elegantly?
Any chance to make org.hibernate.cache.EhCacheProvider more extendable?
Thanks!