Search in sources :

Example 31 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project quasar by puniverse.

the class MonitoringServices method registerMBean.

private void registerMBean() {
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName mxbeanName = new ObjectName("co.paralleluniverse:name=MonitoringServices");
        mbs.registerMBean(this, mxbeanName);
    } catch (InstanceAlreadyExistsException ex) {
        throw new RuntimeException(ex);
    } catch (MBeanRegistrationException ex) {
        ex.printStackTrace();
    } catch (NotCompliantMBeanException ex) {
        throw new AssertionError(ex);
    } catch (MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 32 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project quasar by puniverse.

the class ActorLoader method registerMBean.

private void registerMBean(String mbeanName) throws InstanceAlreadyExistsException {
    try {
        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        final ObjectName mxbeanName = new ObjectName(mbeanName);
        mbs.registerMBean(this, mxbeanName);
    } catch (MBeanRegistrationException ex) {
        LOG.error("exception while registering MBean " + mbeanName, ex);
    } catch (NotCompliantMBeanException ex) {
        throw new AssertionError(ex);
    } catch (MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 33 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project quasar by puniverse.

the class JMXActorMonitor method registerMBean.

private void registerMBean() {
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName mxbeanName = new ObjectName(name);
        if (mbs.isRegistered(mxbeanName)) {
            try {
                LOG.info("MBean named {} is already registered. Unregistering it.", name);
                mbs.unregisterMBean(mxbeanName);
            } catch (InstanceNotFoundException e) {
            }
        }
        mbs.registerMBean(this, mxbeanName);
        MonitoringServices.getInstance().addPerfNotificationListener(this, name);
        this.registered = true;
    } catch (InstanceAlreadyExistsException ex) {
        throw new RuntimeException(ex);
    } catch (MBeanRegistrationException ex) {
        ex.printStackTrace();
    } catch (NotCompliantMBeanException | MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceNotFoundException(javax.management.InstanceNotFoundException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 34 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project quasar by puniverse.

the class JMXActorsMonitor method unregister.

@SuppressWarnings({ "CallToPrintStackTrace", "CallToThreadDumpStack" })
private void unregister() {
    try {
        if (registered) {
            MonitoringServices.getInstance().removePerfNotificationListener(this);
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(mbeanName));
        }
        this.registered = false;
    } catch (InstanceNotFoundException ex) {
        ex.printStackTrace();
    } catch (MBeanRegistrationException ex) {
        ex.printStackTrace();
    } catch (MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 35 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project quasar by puniverse.

the class JMXActorsMonitor method registerMBean.

@SuppressWarnings({ "CallToPrintStackTrace", "CallToThreadDumpStack" })
private void registerMBean() {
    try {
        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        final ObjectName mxbeanName = new ObjectName(mbeanName);
        mbs.registerMBean(this, mxbeanName);
        this.registered = true;
    } catch (InstanceAlreadyExistsException ex) {
        throw new RuntimeException(ex);
    } catch (MBeanRegistrationException ex) {
        ex.printStackTrace();
    } catch (NotCompliantMBeanException ex) {
        throw new AssertionError(ex);
    } catch (MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
    MonitoringServices.getInstance().addPerfNotificationListener(this, mbeanName);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

MBeanRegistrationException (javax.management.MBeanRegistrationException)48 ObjectName (javax.management.ObjectName)39 MalformedObjectNameException (javax.management.MalformedObjectNameException)35 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)31 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)29 InstanceNotFoundException (javax.management.InstanceNotFoundException)21 MBeanServer (javax.management.MBeanServer)20 StandardMBean (javax.management.StandardMBean)8 IOException (java.io.IOException)7 RuntimeOperationsException (javax.management.RuntimeOperationsException)5 MalformedURLException (java.net.MalformedURLException)4 JMRuntimeException (javax.management.JMRuntimeException)3 MBeanException (javax.management.MBeanException)3 ObjectInstance (javax.management.ObjectInstance)3 PrivilegedActionException (java.security.PrivilegedActionException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ReflectionException (javax.management.ReflectionException)2 Test (org.junit.Test)2 Logger (ch.qos.logback.classic.Logger)1