mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
close cachemanager on context destroy
This commit is contained in:
@@ -33,11 +33,15 @@
|
|||||||
|
|
||||||
package sonia.scm.cache;
|
package sonia.scm.cache;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
public interface CacheManager
|
public interface CacheManager extends Closeable
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,6 +56,5 @@ public interface CacheManager
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <K, V> Cache<K, V> getCache(Class<K> key, Class<V> value,
|
public <K, V> Cache<K, V> getCache(Class<K> key, Class<V> value, String name);
|
||||||
String name);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import sonia.scm.cache.CacheManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -89,6 +90,9 @@ public class ScmContextListener extends GuiceServletContextListener
|
|||||||
|
|
||||||
// close StoreFactory
|
// close StoreFactory
|
||||||
IOUtil.close(injector.getInstance(StoreFactory.class));
|
IOUtil.close(injector.getInstance(StoreFactory.class));
|
||||||
|
|
||||||
|
// close CacheManager
|
||||||
|
IOUtil.close( injector.getInstance( CacheManager.class ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
super.contextDestroyed(servletContextEvent);
|
super.contextDestroyed(servletContextEvent);
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ import com.google.inject.Singleton;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
@@ -67,6 +71,20 @@ public class EhCacheManager implements CacheManager
|
|||||||
new net.sf.ehcache.CacheManager(EhCacheManager.class.getResource(CONFIG));
|
new net.sf.ehcache.CacheManager(EhCacheManager.class.getResource(CONFIG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException
|
||||||
|
{
|
||||||
|
cacheManager.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user