in src/main/java/org/apache/geronimo/jcache/simple/SimpleCache.java [95:163]
public SimpleCache(final ClassLoader classLoader, final SimpleManager mgr, final String cacheName,
final SimpleConfiguration<K, V> configuration, final Properties properties,
final ExecutorService executorService) {
manager = mgr;
name = cacheName;
final int capacity = Integer.parseInt(property(properties, cacheName, "capacity", "1000"));
final float loadFactor = Float.parseFloat(property(properties, cacheName, "loadFactor", "0.75"));
final int concurrencyLevel = Integer.parseInt(property(properties, cacheName, "concurrencyLevel", "16"));
delegate = new ConcurrentHashMap<>(capacity, loadFactor, concurrencyLevel);
config = configuration;
pool = executorService;
final long evictionPause = Long.parseLong(
properties.getProperty(cacheName + ".evictionPause", properties.getProperty("evictionPause", "30000")));
if (evictionPause > 0) {
final long maxDeleteByEvictionRun = Long.parseLong(property(properties, cacheName, "maxDeleteByEvictionRun", "100"));
addPoolTask(new EvictionThread(evictionPause, maxDeleteByEvictionRun));
}
serializations = new Serializations(property(properties, cacheName, "serialization.whitelist", null));
final Factory<CacheLoader<K, V>> cacheLoaderFactory = configuration.getCacheLoaderFactory();
if (cacheLoaderFactory == null) {
loader = NoLoader.INSTANCE;
} else {
loader = ExceptionWrapperHandler.newProxy(classLoader, cacheLoaderFactory.create(), CacheLoaderException.class,
CacheLoader.class);
}
final Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory = configuration.getCacheWriterFactory();
if (cacheWriterFactory == null) {
writer = NoWriter.INSTANCE;
} else {
writer = ExceptionWrapperHandler.newProxy(classLoader, cacheWriterFactory.create(), CacheWriterException.class,
CacheWriter.class);
}
final Factory<ExpiryPolicy> expiryPolicyFactory = configuration.getExpiryPolicyFactory();
if (expiryPolicyFactory == null) {
expiryPolicy = new EternalExpiryPolicy();
} else {
expiryPolicy = expiryPolicyFactory.create();
}
for (final CacheEntryListenerConfiguration<K, V> listener : config.getCacheEntryListenerConfigurations()) {
listeners.put(listener, new SimpleListener<>(listener));
}
statistics.setActive(config.isStatisticsEnabled());
final String mgrStr = manager.getURI().toString().replaceAll(",|:|=|\n", ".");
final String cacheStr = name.replaceAll(",|:|=|\n", ".");
try {
cacheConfigObjectName = new ObjectName(
"javax.cache:type=CacheConfiguration," + "CacheManager=" + mgrStr + "," + "Cache=" + cacheStr);
cacheStatsObjectName = new ObjectName(
"javax.cache:type=CacheStatistics," + "CacheManager=" + mgrStr + "," + "Cache=" + cacheStr);
} catch (final Exception e) {
throw new IllegalArgumentException(e);
}
if (config.isManagementEnabled()) {
JMXs.register(cacheConfigObjectName, new SimpleCacheMXBean<K, V>(this));
}
if (config.isStatisticsEnabled()) {
JMXs.register(cacheStatsObjectName, new SimpleCacheStatisticsMXBean(statistics));
}
}