use of org.cache2k.CacheException in project cache2k by cache2k.
the class JmxSupport method managerCreated.
@Override
public void managerCreated(CacheManager m) {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ManagerMXBeanImpl _mBean = new ManagerMXBeanImpl((CacheManagerImpl) m);
String _name = managerName(m);
try {
mbs.registerMBean(_mBean, new ObjectName(_name));
m.getProperties().put(REGISTERED_FLAG, true);
log.debug("Manager created and registered as: " + _name);
} catch (InstanceAlreadyExistsException ignore) {
log.debug("register failure, manager: " + m.getName(), ignore);
} catch (Exception e) {
throw new CacheException("register JMX bean, ObjectName: " + _name, e);
}
}
use of org.cache2k.CacheException in project cache2k by cache2k.
the class JmxSupport method cacheCreated.
@Override
public void cacheCreated(Cache c) {
InternalCache ic = (InternalCache) c;
if (!ic.getCommonMetrics().isDisabled()) {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
String _name = standardName(c.getCacheManager(), c);
try {
mbs.registerMBean(new CacheMXBeanImpl(ic), new ObjectName(_name));
} catch (InstanceAlreadyExistsException ignore) {
log.debug("register failure, cache: " + c.getName(), ignore);
} catch (Exception e) {
throw new CacheException("register JMX bean, ObjectName: " + _name, e);
}
}
}
use of org.cache2k.CacheException in project cache2k by cache2k.
the class JmxSupport method cacheDestroyed.
@Override
public void cacheDestroyed(Cache c) {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
String _name = standardName(c.getCacheManager(), c);
try {
mbs.unregisterMBean(new ObjectName(_name));
} catch (InstanceNotFoundException ignore) {
log.debug("unregister failure, cache: " + c.getName(), ignore);
} catch (Exception e) {
throw new CacheException("unregister JMX bean, ObjectName: " + _name, e);
}
}
use of org.cache2k.CacheException in project cache2k by cache2k.
the class JmxSupport method managerDestroyed.
@Override
public void managerDestroyed(CacheManager m) {
if (!m.getProperties().containsKey(REGISTERED_FLAG)) {
return;
}
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
String _name = managerName(m);
try {
mbs.unregisterMBean(new ObjectName(_name));
} catch (Exception e) {
throw new CacheException("Error unregister JMX bean, ObjectName: " + _name, e);
}
}
Aggregations