-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Extending org.hibernate.cache.EhCacheProvider
PostPosted: Sun Oct 30, 2005 6:08 am 
Newbie

Joined: Mon Oct 10, 2005 1:07 pm
Posts: 13
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.