added caching for the repositorymanager

This commit is contained in:
Sebastian Sdorra
2010-10-14 07:58:51 +02:00
parent 8d8f74bce3
commit e891d762fb
10 changed files with 749 additions and 1 deletions

View File

@@ -0,0 +1,99 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm.cache;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Singleton;
/**
*
* @author Sebastian Sdorra
*/
@Singleton
public class EhCacheManager implements CacheManager
{
/** Field description */
public static final String CONFIG = "/config/ehcache.xml";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public EhCacheManager()
{
cacheManager =
new net.sf.ehcache.CacheManager(EhCacheManager.class.getResource(CONFIG));
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param key
* @param value
* @param name
* @param <K>
* @param <V>
*
* @return
*/
@Override
public <K, V> ExtendedCache<K, V> getExtendedCache(Class<K> key,
Class<V> value, String name)
{
return getCache(key, value, name);
}
/**
* Method description
*
*
* @param key
* @param value
* @param name
* @param <K>
* @param <V>
*
* @return
*/
@Override
public <K, V> SimpleCache<K, V> getSimpleCache(Class<K> key, Class<V> value,
String name)
{
return getCache(key, value, name);
}
/**
* Method description
*
*
* @param key
* @param value
* @param name
* @param <K>
* @param <V>
*
* @return
*/
private <K, V> EhCache<K, V> getCache(Class<K> key, Class<V> value,
String name)
{
return new EhCache<K, V>(cacheManager.getCache(name));
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private net.sf.ehcache.CacheManager cacheManager;
}