use of javax.management.InstanceAlreadyExistsException in project jdk8u_jdk by JetBrains.
the class MXBeanLookup method addReference.
synchronized void addReference(ObjectName name, Object mxbean) throws InstanceAlreadyExistsException {
ObjectName existing = mxbeanToObjectName.get(mxbean);
if (existing != null) {
String multiname = AccessController.doPrivileged(new GetPropertyAction("jmx.mxbean.multiname"));
if (!"true".equalsIgnoreCase(multiname)) {
throw new InstanceAlreadyExistsException("MXBean already registered with name " + existing);
}
}
mxbeanToObjectName.put(mxbean, name);
}
use of javax.management.InstanceAlreadyExistsException in project jdk8u_jdk by JetBrains.
the class ManagementFactoryHelper method addMBean.
/**
* Registers a given MBean if not registered in the MBeanServer;
* otherwise, just return.
*/
private static void addMBean(MBeanServer mbs, Object mbean, String mbeanName) {
try {
final ObjectName objName = Util.newObjectName(mbeanName);
// inner class requires these fields to be final
final MBeanServer mbs0 = mbs;
final Object mbean0 = mbean;
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
public Void run() throws MBeanRegistrationException, NotCompliantMBeanException {
try {
mbs0.registerMBean(mbean0, objName);
return null;
} catch (InstanceAlreadyExistsException e) {
// if an instance with the object name exists in
// the MBeanServer ignore the exception
}
return null;
}
});
} catch (PrivilegedActionException e) {
throw Util.newException(e.getException());
}
}
use of javax.management.InstanceAlreadyExistsException in project ddf by codice.
the class SolrCache method configureMBean.
private void configureMBean() {
LOGGER.debug("Registering Cache Manager Service MBean");
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
try {
objectName = new ObjectName(SolrCacheMBean.OBJECTNAME);
} catch (MalformedObjectNameException e) {
LOGGER.info("Could not create object name", e);
}
try {
try {
mbeanServer.registerMBean(new StandardMBean(this, SolrCacheMBean.class), objectName);
} catch (InstanceAlreadyExistsException e) {
LOGGER.debug("Re-registering Cache Manager MBean");
mbeanServer.unregisterMBean(objectName);
mbeanServer.registerMBean(new StandardMBean(this, SolrCacheMBean.class), objectName);
}
} catch (Exception e) {
LOGGER.debug("Could not register MBean.", e);
}
}
use of javax.management.InstanceAlreadyExistsException in project ddf by codice.
the class QueryMonitor method registerMbean.
private void registerMbean() {
try {
objectName = new ObjectName(QueryMonitor.class.getName() + ":service=querymonitor");
mBeanServer = ManagementFactory.getPlatformMBeanServer();
} catch (MalformedObjectNameException e) {
LOGGER.info("Unable to create Query Monitor Configuration MBean.", e);
}
if (mBeanServer == null) {
return;
}
try {
try {
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Registered Query Monitor Configuration MBean under object name: {}", objectName.toString());
} catch (InstanceAlreadyExistsException e) {
// Try to remove and re-register
mBeanServer.unregisterMBean(objectName);
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Re-registered Query Monitor Configuration MBean");
}
} catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
LOGGER.info("Could not register MBean [{}].", objectName.toString(), e);
}
}
use of javax.management.InstanceAlreadyExistsException in project ddf by codice.
the class KeystoreEditor method registerMbean.
private void registerMbean() {
ObjectName objectName = null;
MBeanServer mBeanServer = null;
try {
objectName = new ObjectName(KeystoreEditor.class.getName() + ":service=keystore");
mBeanServer = ManagementFactory.getPlatformMBeanServer();
} catch (MalformedObjectNameException e) {
LOGGER.info("Unable to create Keystore Editor MBean.", e);
}
if (mBeanServer != null) {
try {
try {
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Registered Keystore Editor MBean under object name: {}", objectName.toString());
} catch (InstanceAlreadyExistsException e) {
// Try to remove and re-register
mBeanServer.unregisterMBean(objectName);
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Re-registered Keystore Editor MBean");
}
} catch (Exception e) {
//objectName is not always non-null because new ObjectName(...) can throw an exception
LOGGER.info("Could not register MBean [{}].", objectName != null ? objectName.toString() : KeystoreEditor.class.getName(), e);
}
}
}
Aggregations