/** Adds the JMX monitoring settings. */ private void addMonitoring() { configuration.setStatisticsEnabled(merged.getBoolean("monitoring.statistics")); configuration.setManagementEnabled(merged.getBoolean("monitoring.management")); }
/** Enables or disables the statistics JMX bean. */ void enableStatistics(boolean enabled) { requireNotClosed(); synchronized (configuration) { if (enabled) { JmxRegistration.registerMXBean(this, statistics, MBeanType.Statistics); } else { JmxRegistration.unregisterMXBean(this, MBeanType.Statistics); } statistics.enable(enabled); configuration.setStatisticsEnabled(enabled); } }
/** Copies the configuration and overlays it on top of the default settings. */ @SuppressWarnings("PMD.AccessorMethodGeneration") private <K, V> CaffeineConfiguration<K, V> resolveConfigurationFor( Configuration<K, V> configuration) { if (configuration instanceof CaffeineConfiguration<?, ?>) { return new CaffeineConfiguration<>((CaffeineConfiguration<K, V>) configuration); } CaffeineConfiguration<K, V> template = TypesafeConfigurator.defaults(rootConfig); if (configuration instanceof CompleteConfiguration<?, ?>) { CompleteConfiguration<K, V> complete = (CompleteConfiguration<K, V>) configuration; template.setReadThrough(complete.isReadThrough()); template.setWriteThrough(complete.isWriteThrough()); template.setManagementEnabled(complete.isManagementEnabled()); template.setStatisticsEnabled(complete.isStatisticsEnabled()); template.getCacheEntryListenerConfigurations() .forEach(template::removeCacheEntryListenerConfiguration); complete.getCacheEntryListenerConfigurations() .forEach(template::addCacheEntryListenerConfiguration); template.setCacheLoaderFactory(complete.getCacheLoaderFactory()); template.setCacheWriterFactory(complete.getCacheWriterFactory()); template.setExpiryPolicyFactory(complete.getExpiryPolicyFactory()); } template.setTypes(configuration.getKeyType(), configuration.getValueType()); template.setStoreByValue(configuration.isStoreByValue()); return template; }
/** Adds the JMX monitoring settings. */ private void addMonitoring() { configuration.setStatisticsEnabled(merged.getBoolean("monitoring.statistics")); configuration.setManagementEnabled(merged.getBoolean("monitoring.management")); }
/** Enables or disables the statistics JMX bean. */ void enableStatistics(boolean enabled) { requireNotClosed(); synchronized (configuration) { if (enabled) { JmxRegistration.registerMXBean(this, statistics, MBeanType.Statistics); } else { JmxRegistration.unregisterMXBean(this, MBeanType.Statistics); } statistics.enable(enabled); configuration.setStatisticsEnabled(enabled); } }
/** Copies the configuration and overlays it on top of the default settings. */ @SuppressWarnings("PMD.AccessorMethodGeneration") private <K, V> CaffeineConfiguration<K, V> resolveConfigurationFor( Configuration<K, V> configuration) { if (configuration instanceof CaffeineConfiguration<?, ?>) { return new CaffeineConfiguration<>((CaffeineConfiguration<K, V>) configuration); } CaffeineConfiguration<K, V> template = TypesafeConfigurator.defaults(rootConfig); if (configuration instanceof CompleteConfiguration<?, ?>) { CompleteConfiguration<K, V> complete = (CompleteConfiguration<K, V>) configuration; template.setReadThrough(complete.isReadThrough()); template.setWriteThrough(complete.isWriteThrough()); template.setManagementEnabled(complete.isManagementEnabled()); template.setStatisticsEnabled(complete.isStatisticsEnabled()); template.getCacheEntryListenerConfigurations() .forEach(template::removeCacheEntryListenerConfiguration); complete.getCacheEntryListenerConfigurations() .forEach(template::addCacheEntryListenerConfiguration); template.setCacheLoaderFactory(complete.getCacheLoaderFactory()); template.setCacheWriterFactory(complete.getCacheWriterFactory()); template.setExpiryPolicyFactory(complete.getExpiryPolicyFactory()); } template.setTypes(configuration.getKeyType(), configuration.getValueType()); template.setStoreByValue(configuration.isStoreByValue()); return template; }