use of javax.management.InstanceAlreadyExistsException in project aries by apache.
the class JMXAgentImpl method registerMBeans.
/**
* @see org.apache.aries.jmx.agent.JMXAgent#registerMBeans(javax.management.MBeanServer)
*/
public synchronized void registerMBeans(final MBeanServer server) {
for (MBeanHandler mbeanHandler : mbeansHandlers.keySet()) {
if (mbeansHandlers.get(mbeanHandler) == Boolean.TRUE) {
String name = mbeanHandler.getName();
StandardMBean mbean = mbeanHandler.getMbean();
if (mbean != null) {
try {
logger.log(LogService.LOG_INFO, "Registering " + mbean.getMBeanInterface().getName() + " to MBeanServer " + server + " with name " + name);
server.registerMBean(mbean, new ObjectName(name));
} catch (InstanceAlreadyExistsException e) {
logger.log(LogService.LOG_ERROR, "MBean is already registered", e);
} catch (MBeanRegistrationException e) {
logger.log(LogService.LOG_ERROR, "Can't register MBean", e);
} catch (NotCompliantMBeanException e) {
logger.log(LogService.LOG_ERROR, "MBean is not compliant MBean", e);
} catch (MalformedObjectNameException e) {
logger.log(LogService.LOG_ERROR, "Try to register with no valid objectname", e);
} catch (NullPointerException e) {
logger.log(LogService.LOG_ERROR, "Name of objectname can't be null", e);
}
}
}
}
mbeanServers.put(server, Boolean.TRUE);
}
use of javax.management.InstanceAlreadyExistsException in project aries by apache.
the class JMXAgentImpl method registerMBean.
/**
* @see org.apache.aries.jmx.agent.JMXAgent#registerMBean(org.apache.aries.jmx.MBeanHandler)
*/
public synchronized void registerMBean(final MBeanHandler mBeanHandler) {
for (MBeanServer server : mbeanServers.keySet()) {
String name = mBeanHandler.getName();
StandardMBean mbean = mBeanHandler.getMbean();
try {
logger.log(LogService.LOG_INFO, "Registering " + mbean.getMBeanInterface().getName() + " to MBeanServer " + server + " with name " + name);
server.registerMBean(mbean, new ObjectName(name));
} catch (InstanceAlreadyExistsException e) {
logger.log(LogService.LOG_ERROR, "MBean is already registered", e);
} catch (MBeanRegistrationException e) {
logger.log(LogService.LOG_ERROR, "Can't register MBean", e);
} catch (NotCompliantMBeanException e) {
logger.log(LogService.LOG_ERROR, "MBean is not compliant MBean, Stopping registration", e);
return;
} catch (MalformedObjectNameException e) {
logger.log(LogService.LOG_ERROR, "Try to register with no valid objectname, Stopping registration", e);
return;
} catch (NullPointerException e) {
logger.log(LogService.LOG_ERROR, "Name of objectname can't be null, Stopping registration", e);
return;
}
}
mbeansHandlers.put(mBeanHandler, Boolean.TRUE);
}
use of javax.management.InstanceAlreadyExistsException in project geode by apache.
the class ManagementAgent method registerAccessControlMBean.
private void registerAccessControlMBean() {
try {
AccessControlMBean acc = new AccessControlMBean();
ObjectName accessControlMBeanON = new ObjectName(ResourceConstants.OBJECT_NAME_ACCESSCONTROL);
MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
Set<ObjectName> names = platformMBeanServer.queryNames(accessControlMBeanON, null);
if (names.isEmpty()) {
try {
platformMBeanServer.registerMBean(acc, accessControlMBeanON);
logger.info("Registered AccessControlMBean on " + accessControlMBeanON);
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
throw new GemFireConfigException("Error while configuring accesscontrol for jmx resource", e);
}
}
} catch (MalformedObjectNameException e) {
throw new GemFireConfigException("Error while configuring accesscontrol for jmx resource", e);
}
}
use of javax.management.InstanceAlreadyExistsException in project geode by apache.
the class MBeanJMXAdapter method registerMBean.
/**
* This method will register an MBean in GemFire domain. Even if the client provides a domain name
* it will be ignored and GemFire domain name will be used.
*
* This method checks the local Filter for registering the MBean. If filtered the MBean wont be
* registered. Although the filter will remember the filtered MBean and register it once the
* filter is removed.
*
* @param object
* @param objectName
* @return modifed ObjectName
*/
public ObjectName registerMBean(Object object, ObjectName objectName, boolean isGemFireMBean) {
ObjectName newObjectName = objectName;
try {
if (!isGemFireMBean) {
String member = getMemberNameOrId(distMember);
String objectKeyProperty = objectName.getKeyPropertyListString();
newObjectName = ObjectName.getInstance(OBJECTNAME__PREFIX + objectKeyProperty + KEYVAL_SEPARATOR + "member=" + member);
}
mbeanServer.registerMBean(object, newObjectName);
this.localGemFireMBean.put(newObjectName, object);
} catch (InstanceAlreadyExistsException e) {
throw new ManagementException(e);
} catch (MBeanRegistrationException e) {
throw new ManagementException(e);
} catch (NotCompliantMBeanException e) {
throw new ManagementException(e);
} catch (MalformedObjectNameException e) {
throw new ManagementException(e);
} catch (NullPointerException e) {
throw new ManagementException(e);
}
return newObjectName;
}
use of javax.management.InstanceAlreadyExistsException in project ddf by codice.
the class Geocoding method registerMbean.
private void registerMbean() {
ObjectName objectName = null;
MBeanServer mBeanServer = null;
try {
objectName = new ObjectName(Geocoding.class.getName() + ":service=geocoding");
mBeanServer = ManagementFactory.getPlatformMBeanServer();
} catch (MalformedObjectNameException e) {
LOGGER.info("Unable to create Geocoding Configuration MBean.", e);
}
if (mBeanServer != null) {
try {
try {
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Registered Geocoding 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 Geocoding Configuration 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() : Geocoding.class.getName(), e);
}
}
}
Aggregations