p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.max_idle", "30000");
p.setProperty("hibernate.cache.infinispan.entity.cfg", "myentity-cache");
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
InfinispanRegionFactory factory = new InfinispanRegionFactory();
factory.start(null, p);
EmbeddedCacheManager manager = factory.getCacheManager();
try {
assertFalse(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
CacheAdapter cache = region.getCacheAdapter();
assertFalse(factory.getTypeOverrides().get("entity").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, null);
cache = region.getCacheAdapter();
assertFalse(factory.getTypeOverrides().get("com.acme.Person").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
final String query = "org.hibernate.cache.StandardQueryCache";
QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
cache = queryRegion.getCacheAdapter();
assertFalse(factory.getTypeOverrides().get("query").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
final String timestamps = "org.hibernate.cache.UpdateTimestampsCache";
Configuration config = new Configuration();
config.setFetchInMemoryState(false);
manager.defineConfiguration("timestamps", config);
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
cache = timestampsRegion.getCacheAdapter();
assertFalse(factory.getTypeOverrides().get("timestamps").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
cache = collectionRegion.getCacheAdapter();
assertFalse(factory.getTypeOverrides().get("collection").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
} finally {
factory.stop();
}
}