com.jpattern.service.cache.simple.SimpleCacheService Maven / Gradle / Ivy
package com.jpattern.service.cache.simple;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jpattern.service.cache.ICache;
import com.jpattern.service.cache.ICacheService;
import com.jpattern.service.cache.NullCache;
/**
*
* @author Francesco Cina'
*
* 24/set/2011
*/
public class SimpleCacheService implements ICacheService, Serializable {
private static final long serialVersionUID = 1L;
private final String name;
private final Map cachesMap = new HashMap();
public SimpleCacheService(String name, List caches) {
this.name = name;
for (ICache cache : caches) {
cachesMap.put(cache.getName(), cache);
}
}
@Override
public String getName() {
return name;
}
@Override
public ICache getCache(String cacheName) {
if (cachesMap.containsKey(cacheName)) {
return cachesMap.get(cacheName);
}
return new NullCache();
}
@Override
public void stopService() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy