String globalStats = extractProperty(INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
if (globalStats != null) {
// Hack to enable global JMX stats being enabled in both 5.1 and 5.2
// 1. Create a configuration builder holder
ConfigurationBuilderHolder holder = new ConfigurationBuilderHolder();
// 2. Build global configuration with custom settings
GlobalConfigurationBuilder globalBuilder = holder.getGlobalConfigurationBuilder();
globalBuilder.read(manager.getCacheManagerConfiguration());
globalBuilder.globalJmxStatistics().enabled(Boolean.parseBoolean(globalStats));
// 3. Build default configuration
holder.getDefaultConfigurationBuilder().read(manager.getDefaultCacheConfiguration());
// 4. Build all defined caches
for (String cacheName : manager.getCacheNames()){
ConfigurationBuilder builder = holder.newConfigurationBuilder(cacheName);
builder.read(manager.getCacheConfiguration(cacheName));
}
// 5. Discard existing cache manager and create a brand new one
manager.stop();