use of net.sf.ehcache.config.Configuration in project hibernate-orm by hibernate.
the class SingletonEhCacheRegionFactory method start.
@Override
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
this.settings = settings;
try {
String configurationResourceName = null;
if (properties != null) {
configurationResourceName = (String) properties.get(NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME);
}
if (configurationResourceName == null || configurationResourceName.length() == 0) {
manager = CacheManager.create();
REFERENCE_COUNT.incrementAndGet();
} else {
URL url;
try {
url = new URL(configurationResourceName);
} catch (MalformedURLException e) {
if (!configurationResourceName.startsWith("/")) {
configurationResourceName = "/" + configurationResourceName;
LOG.debugf("prepending / to %s. It should be placed in the root of the classpath rather than in a package.", configurationResourceName);
}
url = loadResource(configurationResourceName);
}
final Configuration configuration = HibernateEhcacheUtils.loadAndCorrectConfiguration(url);
manager = CacheManager.create(configuration);
REFERENCE_COUNT.incrementAndGet();
}
mbeanRegistrationHelper.registerMBean(manager, properties);
} catch (net.sf.ehcache.CacheException e) {
throw new CacheException(e);
}
}
use of net.sf.ehcache.config.Configuration in project spring-framework by spring-projects.
the class EhCacheCacheTests method setUp.
@Before
public void setUp() {
cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests").defaultCache(new CacheConfiguration("default", 100)));
nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100));
cacheManager.addCache(nativeCache);
cache = new EhCacheCache(nativeCache);
}
use of net.sf.ehcache.config.Configuration in project spring-framework by spring-projects.
the class EhCacheManagerUtils method buildCacheManager.
/**
* Build an EhCache {@link CacheManager} from the default configuration.
* <p>The CacheManager will be configured from "ehcache.xml" in the root of the class path
* (that is, default EhCache initialization - as defined in the EhCache docs - will apply).
* If no configuration file can be found, a fail-safe fallback configuration will be used.
* @param name the desired name of the cache manager
* @return the new EhCache CacheManager
* @throws CacheException in case of configuration parsing failure
*/
public static CacheManager buildCacheManager(String name) throws CacheException {
Configuration configuration = ConfigurationFactory.parseConfiguration();
configuration.setName(name);
return new CacheManager(configuration);
}
use of net.sf.ehcache.config.Configuration in project libresonic by Libresonic.
the class CacheFactory method afterPropertiesSet.
public void afterPropertiesSet() throws Exception {
Configuration configuration = ConfigurationFactory.parseConfiguration();
// Override configuration to make sure cache is stored in Libresonic home dir.
File cacheDir = new File(SettingsService.getLibresonicHome(), "cache");
configuration.getDiskStoreConfiguration().setPath(cacheDir.getPath());
cacheManager = CacheManager.create(configuration);
}
use of net.sf.ehcache.config.Configuration in project gocd by gocd.
the class UserCacheFactory method createCacheManager.
private CacheManager createCacheManager() {
Configuration configuration = new Configuration();
configuration.setDefaultCacheConfiguration(new CacheConfiguration("cache", 10000));
return new CacheManager(configuration);
}
Aggregations