Search in sources :

Example 11 with InstanceAlreadyExistsException

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");
}
Also used : InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Example 12 with InstanceAlreadyExistsException

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);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException)

Example 13 with InstanceAlreadyExistsException

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);
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ObjectInstance(javax.management.ObjectInstance) MBeanRegistrationException(javax.management.MBeanRegistrationException)

Example 14 with InstanceAlreadyExistsException

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);
        }
    }
}
Also used : InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 15 with InstanceAlreadyExistsException

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;
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) Signature(org.aspectj.lang.Signature) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Aggregations

InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)49 ObjectName (javax.management.ObjectName)38 MalformedObjectNameException (javax.management.MalformedObjectNameException)30 MBeanRegistrationException (javax.management.MBeanRegistrationException)29 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)28 MBeanServer (javax.management.MBeanServer)25 InstanceNotFoundException (javax.management.InstanceNotFoundException)14 ObjectInstance (javax.management.ObjectInstance)8 IOException (java.io.IOException)6 StandardMBean (javax.management.StandardMBean)6 Test (org.junit.Test)3 MalformedURLException (java.net.MalformedURLException)2 CacheException (javax.cache.CacheException)2 JMRuntimeException (javax.management.JMRuntimeException)2 MBeanException (javax.management.MBeanException)2 ReflectionException (javax.management.ReflectionException)2 RuntimeOperationsException (javax.management.RuntimeOperationsException)2 Logger (ch.qos.logback.classic.Logger)1 JMXConfigurator (ch.qos.logback.classic.jmx.JMXConfigurator)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1