close cachemanager on context destroy

This commit is contained in:
Sebastian Sdorra
2011-02-12 18:10:32 +01:00
parent 4d6707c05e
commit 8a8ab5f6e6
3 changed files with 28 additions and 3 deletions

View File

@@ -33,11 +33,15 @@
package sonia.scm.cache;
//~--- JDK imports ------------------------------------------------------------
import java.io.Closeable;
/**
*
* @author Sebastian Sdorra
*/
public interface CacheManager
public interface CacheManager extends Closeable
{
/**
@@ -52,6 +56,5 @@ public interface CacheManager
*
* @return
*/
public <K, V> Cache<K, V> getCache(Class<K> key, Class<V> value,
String name);
public <K, V> Cache<K, V> getCache(Class<K> key, Class<V> value, String name);
}

View File

@@ -55,6 +55,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContextEvent;
import sonia.scm.cache.CacheManager;
/**
*
@@ -89,6 +90,9 @@ public class ScmContextListener extends GuiceServletContextListener
// close StoreFactory
IOUtil.close(injector.getInstance(StoreFactory.class));
// close CacheManager
IOUtil.close( injector.getInstance( CacheManager.class ) );
}
super.contextDestroyed(servletContextEvent);

View File

@@ -40,6 +40,10 @@ import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
*
* @author Sebastian Sdorra
@@ -67,6 +71,20 @@ public class EhCacheManager implements CacheManager
new net.sf.ehcache.CacheManager(EhCacheManager.class.getResource(CONFIG));
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @throws IOException
*/
@Override
public void close() throws IOException
{
cacheManager.shutdown();
}
//~--- get methods ----------------------------------------------------------
/**