use of javax.management.InstanceAlreadyExistsException in project jdk8u_jdk by JetBrains.
the class SameObjectTwoNamesTest method main.
public static void main(String[] args) throws Exception {
boolean expectException = (System.getProperty("jmx.mxbean.multiname") == null);
try {
ObjectName objectName1 = new ObjectName("test:index=1");
ObjectName objectName2 = new ObjectName("test:index=2");
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
MXBC_SimpleClass01 mxBeanObject = new MXBC_SimpleClass01();
mbs.registerMBean(mxBeanObject, objectName1);
mbs.registerMBean(mxBeanObject, objectName2);
if (expectException) {
throw new Exception("TEST FAILED: " + "InstanceAlreadyExistsException was not thrown");
} else
System.out.println("Correctly got no exception with compat property");
} catch (InstanceAlreadyExistsException e) {
if (expectException) {
System.out.println("Got expected InstanceAlreadyExistsException:");
e.printStackTrace(System.out);
} else {
throw new Exception("TEST FAILED: Got exception even though compat property set", e);
}
}
System.out.println("TEST PASSED");
}
use of javax.management.InstanceAlreadyExistsException in project aries by apache.
the class Activator method registerMBeans.
protected void registerMBeans(MBeanServer mbeanServer) {
// register BlueprintStateMBean to MBean server
LOGGER.debug("Registering bundle state monitor with MBeanServer: {} with name: {}", mbeanServer, blueprintStateName);
try {
StandardMBean blueprintState = new RegistrableStandardEmitterMBean(new BlueprintState(bundleContext), BlueprintStateMBean.class);
mbeanServer.registerMBean(blueprintState, blueprintStateName);
} catch (InstanceAlreadyExistsException e) {
LOGGER.debug("Cannot register BlueprintStateMBean");
} catch (MBeanRegistrationException e) {
LOGGER.error("Cannot register BlueprintStateMBean", e);
} catch (NotCompliantMBeanException e) {
LOGGER.error("Cannot register BlueprintStateMBean", e);
}
// register BlueprintMetadataMBean to MBean server
LOGGER.debug("Registering bundle metadata monitor with MBeanServer: {} with name: {}", mbeanServer, blueprintMetadataName);
try {
StandardMBean blueprintMetadata = new StandardMBean(new BlueprintMetadata(bundleContext), BlueprintMetadataMBean.class);
mbeanServer.registerMBean(blueprintMetadata, blueprintMetadataName);
} catch (InstanceAlreadyExistsException e) {
LOGGER.debug("Cannot register BlueprintMetadataMBean");
} catch (MBeanRegistrationException e) {
LOGGER.error("Cannot register BlueprintMetadataMBean", e);
} catch (NotCompliantMBeanException e) {
LOGGER.error("Cannot register BlueprintMetadataMBean", e);
}
}
use of javax.management.InstanceAlreadyExistsException 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.InstanceAlreadyExistsException in project deltaspike by apache.
the class ConfigurationExtension method registerConfigMBean.
public static void registerConfigMBean() {
String appName = ConfigResolver.getPropertyValue(ConfigResolver.DELTASPIKE_APP_NAME_CONFIG);
if (appName != null && appName.length() > 0) {
try {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ClassLoader tccl = ClassUtils.getClassLoader(ConfigurationExtension.class);
DeltaSpikeConfigInfo cfgMBean = new DeltaSpikeConfigInfo(tccl);
ObjectName name = new ObjectName("deltaspike.config." + appName + ":type=DeltaSpikeConfig");
mBeanServer.registerMBean(cfgMBean, name);
} catch (InstanceAlreadyExistsException iae) {
// all fine, the CfgBean got already registered.
// Most probably by the ServletConfigListener
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
use of javax.management.InstanceAlreadyExistsException in project uPortal by Jasig.
the class RequestCacheAspect method getCacheStatistics.
protected final CacheStatistics getCacheStatistics(ProceedingJoinPoint pjp, RequestCache requestCache) {
final Signature signature = pjp.getSignature();
final String signatureString = signature.toString();
CacheStatistics cacheStatistics = this.methodStats.get(signatureString);
if (cacheStatistics == null) {
final CacheStatistics newStats = new CacheStatistics();
cacheStatistics = ConcurrentMapUtils.putIfAbsent(this.methodStats, signatureString, newStats);
if (this.mBeanExportOperations != null && cacheStatistics == newStats) {
final String nameString = "uPortal:section=Cache,RequestCache=RequestCache,name=" + EhcacheHibernateMbeanNames.mbeanSafe(signatureString);
try {
final ObjectName name = new ObjectName(nameString);
registerMbean(cacheStatistics, name);
} catch (MalformedObjectNameException e) {
logger.warn("Failed to create ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
} catch (NullPointerException e) {
logger.warn("Failed to create ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
} catch (InstanceAlreadyExistsException e) {
logger.warn("ObjectName {} is already registered, the corresponding CacheStatistics will not be registered with JMX", nameString, e);
} catch (MBeanRegistrationException e) {
logger.warn("Failed to register ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
} catch (NotCompliantMBeanException e) {
logger.warn("Failed to register ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
}
}
}
return cacheStatistics;
}
Aggregations