use of javax.management.NotCompliantMBeanException in project tomcat by apache.
the class BaseGenericObjectPool method jmxRegister.
/**
* Registers the pool with the platform MBean server.
* The registered name will be
* <code>jmxNameBase + jmxNamePrefix + i</code> where i is the least
* integer greater than or equal to 1 such that the name is not already
* registered. Swallows MBeanRegistrationException, NotCompliantMBeanException
* returning null.
*
* @param config Pool configuration
* @param jmxNameBase default base JMX name for this pool
* @param jmxNamePrefix name prefix
* @return registered ObjectName, null if registration fails
*/
private ObjectName jmxRegister(final BaseObjectPoolConfig config, final String jmxNameBase, String jmxNamePrefix) {
ObjectName objectName = null;
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
int i = 1;
boolean registered = false;
String base = config.getJmxNameBase();
if (base == null) {
base = jmxNameBase;
}
while (!registered) {
try {
ObjectName objName;
// only one so the names are cleaner.
if (i == 1) {
objName = new ObjectName(base + jmxNamePrefix);
} else {
objName = new ObjectName(base + jmxNamePrefix + i);
}
mbs.registerMBean(this, objName);
objectName = objName;
registered = true;
} catch (final MalformedObjectNameException e) {
if (BaseObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX.equals(jmxNamePrefix) && jmxNameBase.equals(base)) {
// Shouldn't happen. Skip registration if it does.
registered = true;
} else {
// Must be an invalid name. Use the defaults instead.
jmxNamePrefix = BaseObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX;
base = jmxNameBase;
}
} catch (final InstanceAlreadyExistsException e) {
// Increment the index and try again
i++;
} catch (final MBeanRegistrationException e) {
// Shouldn't happen. Skip registration if it does.
registered = true;
} catch (final NotCompliantMBeanException e) {
// Shouldn't happen. Skip registration if it does.
registered = true;
}
}
return objectName;
}
use of javax.management.NotCompliantMBeanException in project hadoop by apache.
the class FsDatasetImpl method registerMBean.
/**
* Register the FSDataset MBean using the name
* "hadoop:service=DataNode,name=FSDatasetState-<datanodeUuid>"
*/
void registerMBean(final String datanodeUuid) {
// package naming for mbeans and their impl.
try {
StandardMBean bean = new StandardMBean(this, FSDatasetMBean.class);
mbeanName = MBeans.register("DataNode", "FSDatasetState-" + datanodeUuid, bean);
} catch (NotCompliantMBeanException e) {
LOG.warn("Error registering FSDatasetState MBean", e);
}
LOG.info("Registered FSDatasetState MBean");
}
use of javax.management.NotCompliantMBeanException in project aries by apache.
the class MBeanHolder method register.
void register(final MBeanServer server) {
ObjectInstance instance;
try {
instance = server.registerMBean(mbean, requestedObjectName);
registrations.put(server, instance.getObjectName());
} catch (InstanceAlreadyExistsException e) {
log.error("register: Failure registering MBean " + mbean, e);
} catch (MBeanRegistrationException e) {
log.error("register: Failure registering MBean " + mbean, e);
} catch (NotCompliantMBeanException e) {
log.error("register: Failure registering MBean " + mbean, e);
}
}
use of javax.management.NotCompliantMBeanException in project datanucleus-rdbms by datanucleus.
the class BasicDataSource method jmxRegister.
private void jmxRegister() {
// Return immediately if this DataSource has already been registered
if (registeredJmxName != null) {
return;
}
// Return immediately if no JMX name has been specified
String requestedName = getJmxName();
if (requestedName == null) {
return;
}
ObjectName oname;
try {
oname = new ObjectName(requestedName);
} catch (MalformedObjectNameException e) {
log.warn("The requested JMX name [" + requestedName + "] was not valid and will be ignored.");
return;
}
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
mbs.registerMBean(this, oname);
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
log.warn("Failed to complete JMX registration", e);
}
}
use of javax.management.NotCompliantMBeanException in project SEPA by arces-wot.
the class SEPABeans method registerMBean.
public static void registerMBean(final String mBeanObjectName, final Object mBean) {
try {
final ObjectName name = new ObjectName(mBeanObjectName);
mbs.registerMBean(mBean, name);
} catch (MalformedObjectNameException badObjectName) {
logger.error(badObjectName.getMessage());
} catch (InstanceAlreadyExistsException duplicateMBeanInstance) {
logger.error(duplicateMBeanInstance.getMessage());
} catch (MBeanRegistrationException mbeanRegistrationProblem) {
logger.error(mbeanRegistrationProblem.getMessage());
} catch (NotCompliantMBeanException badMBean) {
logger.error(badMBean.getMessage());
}
}
Aggregations