All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jpattern.service.cache.ehcache.EhCacheService Maven / Gradle / Ivy

There is a newer version: 3.6.2
Show newest version
package com.jpattern.service.cache.ehcache;

import com.jpattern.service.cache.ICache;
import com.jpattern.service.cache.ICacheService;
import com.jpattern.service.cache.statistics.ICacheStatisticsManager;

import net.sf.ehcache.CacheManager;

/**
 * 
 * @author Francesco Cina'
 *
 * 2 May 2011
 */
public class EhCacheService implements ICacheService {

	private final String name;
	private final CacheManager cacheManager;
	private final ICacheStatisticsManager cacheStatisticsManager;

	public EhCacheService(String name, IEhCacheServiceConfig ehCacheServiceConfig) {
		this.name = name;
		this.cacheManager = ehCacheServiceConfig.getCacheManager();
		this.cacheStatisticsManager = ehCacheServiceConfig.getCacheStatisticsManager();
	}
	
	@Override
	public String getName() {
		return name;
	}

	@Override
	public ICache getCache(String cacheName) {
		return new EhCache(cacheName, cacheManager, cacheStatisticsManager.getCacheStatistics(cacheName));
	}

	@Override
	public void stopService() {
		cacheManager.shutdown();		
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy