public void create(boolean jmxEnabled, boolean withCacheStats) { /* * Add in a shutdown hook */ Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { shutdown(); } catch (Throwable t) { // I really do want to swallow this, and make the shutdown clean for // others } } }); // register the cache manager with JMX if (jmxEnabled) { MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); ManagementService.registerMBeans(cacheManager, mBeanServer, true, true, true, withCacheStats); } }
@Override public void start() { MBeanServer mbeanServer = _repo.findInstance(MBeanServer.class); if (mbeanServer != null) { _jmxService = new ManagementService(_cacheManager, mbeanServer, true, true, true, true); try { _jmxService.init(); } catch (CacheException ex) { if (ex.getCause() instanceof InstanceAlreadyExistsException == false) { throw ex; } } } }
protected void registerJmxCacheManager(ComponentRepository repo) { MBeanServer jmx = repo.findInstance(MBeanServer.class); if (jmx != null) { Set<CacheManager> set = Collections.newSetFromMap(new IdentityHashMap<CacheManager, Boolean>()); set.addAll(repo.getInstances(CacheManager.class)); for (CacheManager mgr : set) { ManagementService jmxService = new ManagementService(mgr, jmx, true, true, true, true); repo.registerLifecycle(new CacheManagerLifecycle(jmxService)); } } }
public synchronized static CacheManager getEHCacheManager() { // lazy-init if (MANAGER == null) { MANAGER = CacheManager.create(); // register MBean MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); ManagementService.registerMBeans(MANAGER, mBeanServer, true, true, true, true); } return MANAGER; }
@Bean public String dummyBean(MBeanServer mBeanServer, CacheManager cacheManager) { // This check is only relevant for running integration tests which reuse a application context if (!Arrays.asList(mBeanServer.getDomains()).contains("net.sf.ehcache")) { ManagementService.registerMBeans(cacheManager, mBeanServer, true, true, true, true, true); } return "dummyBean"; }
@PostConstruct public void init() { // The CacheManager has a static List of all CM instances. for(CacheManager cacheMgr : CacheManager.ALL_CACHE_MANAGERS) { ManagementService.registerMBeans(cacheMgr, mbeanServer, registerManager, registerCaches, registerConfigurations, registerStatistics); logger.info("Registering EhCache CacheManager with MBean server " + cacheMgr.getName()); } }
@Bean(destroyMethod="dispose",initMethod="init") //@Lazy(value=false) //-- also enable statistics in ehcache.xml @DependsOn(value = {"ehCacheManagerFactoryBean","mbeanServer"}) public ManagementService ehCacheManagementService() { ManagementService managementService = new ManagementService(cacheManager, mbeanServer, true, true, true, true); return managementService; }
/** * Init JMX monitoring configuration */ private void initJmxMonitoring( ) { MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer( ); boolean bRegisterCacheManager = AppPropertiesService.getProperty( PROPERTY_MONITOR_CACHE_MANAGER, FALSE ).equals( TRUE ); boolean bRegisterCaches = AppPropertiesService.getProperty( PROPERTY_MONITOR_CACHES, FALSE ).equals( TRUE ); boolean bRegisterCacheConfigurations = AppPropertiesService.getProperty( PROPERTY_MONITOR_CACHE_CONFIGURATIONS, FALSE ).equals( TRUE ); boolean bRegisterCacheStatistics = AppPropertiesService.getProperty( PROPERTY_MONITOR_CACHE_STATISTICS, FALSE ).equals( TRUE ); ManagementService .registerMBeans( _manager, mBeanServer, bRegisterCacheManager, bRegisterCaches, bRegisterCacheConfigurations, bRegisterCacheStatistics ); }
private void registerCacheMBean() { CacheManager manager = CacheManager.getCacheManager(CacheManager.DEFAULT_NAME); MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); ManagementService.registerMBeans(manager, mBeanServer, false, false, true, true); }
CacheManagerLifecycle(ManagementService jmxService) { _jmxService = jmxService; }
public void register(CacheManager cacheManager) { log.info("Registering Cache Provider with JMXBeanServer "+mBeanServer); ManagementService.registerMBeans(cacheManager, mBeanServer, registerCacheManager, registerCaches, registerCacheConfigurations, registerCacheStatistics); }
private void register() { // register ehcache as MBean ManagementService.registerMBeans(CacheManager.getInstance(), server, true, true, true, true); }