Search in sources :

Example 11 with StandardMBean

use of javax.management.StandardMBean in project Payara by payara.

the class BootAMX method create.

/**
 *    Create an instance of the booter.
 */
public static synchronized BootAMX create(final ServiceLocator habitat, final MBeanServer server) {
    final BootAMX booter = new BootAMX(habitat, server);
    final ObjectName objectName = getBootAMXMBeanObjectName();
    try {
        final StandardMBean mbean = new StandardMBean(booter, BootAMXMBean.class);
        if (!server.registerMBean(mbean, objectName).getObjectName().equals(objectName)) {
            throw new IllegalStateException();
        }
    } catch (JMException e) {
        e.printStackTrace();
        throw new IllegalStateException(e);
    }
    return booter;
}
Also used : StandardMBean(javax.management.StandardMBean) JMException(javax.management.JMException) ObjectName(javax.management.ObjectName)

Example 12 with StandardMBean

use of javax.management.StandardMBean in project fabric8 by jboss-fuse.

the class JolokiaMXBeanProxy method getMXBeanProxy.

@SuppressWarnings("unchecked")
public static <T extends Object> T getMXBeanProxy(String serviceURL, ObjectName objectName, Class<T> mxbeanInterface, String username, String password, MBeanInfo mbeanInfo) {
    // [TODO] this should be obtaind remotely over jolokia
    if (mbeanInfo == null) {
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        try {
            try {
                StandardMBean impl = new StandardMBean(Mockito.mock(mxbeanInterface), mxbeanInterface, true);
                server.registerMBean(impl, objectName);
                mbeanInfo = server.getMBeanInfo(objectName);
            } finally {
                if (server.isRegistered(objectName)) {
                    server.unregisterMBean(objectName);
                }
            }
        } catch (Exception ex) {
            throw new IllegalStateException("Cannot obtain MBeanInfo", ex);
        }
    }
    ClassLoader classLoader = mxbeanInterface.getClassLoader();
    InvocationHandler handler = new MXBeanInvocationHandler(serviceURL, objectName, username, password, classLoader, mbeanInfo);
    return (T) Proxy.newProxyInstance(classLoader, new Class<?>[] { mxbeanInterface }, handler);
}
Also used : StandardMBean(javax.management.StandardMBean) InvocationHandler(java.lang.reflect.InvocationHandler) OpenDataException(javax.management.openmbean.OpenDataException) MBeanServer(javax.management.MBeanServer)

Example 13 with StandardMBean

use of javax.management.StandardMBean in project smscgateway by RestComm.

the class MProcManagement method registerMProcRuleMbean.

private void registerMProcRuleMbean(MProcRuleMBean mProcRule) {
    try {
        ObjectName esmeObjNname = new ObjectName(SmscManagement.JMX_DOMAIN + ":layer=MProcRule,name=" + mProcRule.getId());
        StandardMBean esmeMxBean = new StandardMBean(mProcRule, MProcRuleMBean.class, true);
        if (this.mbeanServer != null)
            this.mbeanServer.registerMBean(esmeMxBean, esmeObjNname);
    } catch (InstanceAlreadyExistsException e) {
        logger.error(String.format("Error while registering MBean for MProcRule %d", mProcRule.getId()), e);
    } catch (MBeanRegistrationException e) {
        logger.error(String.format("Error while registering MBean for MProcRule %d", mProcRule.getId()), e);
    } catch (NotCompliantMBeanException e) {
        logger.error(String.format("Error while registering MBean for MProcRule %d", mProcRule.getId()), e);
    } catch (MalformedObjectNameException e) {
        logger.error(String.format("Error while registering MBean for MProcRule %d", mProcRule.getId()), e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 14 with StandardMBean

use of javax.management.StandardMBean in project smscgateway by RestComm.

the class SipManagement method registerSipMbean.

private void registerSipMbean(Sip esme) {
    try {
        ObjectName esmeObjNname = new ObjectName(SmscManagement.JMX_DOMAIN + ":layer=Sip,name=" + esme.getName());
        StandardMBean esmeMxBean = new StandardMBean(esme, SipMBean.class, true);
        if (this.mbeanServer != null)
            this.mbeanServer.registerMBean(esmeMxBean, esmeObjNname);
    } catch (InstanceAlreadyExistsException e) {
        logger.error(String.format("Error while registering MBean for SIP %s", esme.getName()), e);
    } catch (MBeanRegistrationException e) {
        logger.error(String.format("Error while registering MBean for SIP %s", esme.getName()), e);
    } catch (NotCompliantMBeanException e) {
        logger.error(String.format("Error while registering MBean for SIP %s", esme.getName()), e);
    } catch (MalformedObjectNameException e) {
        logger.error(String.format("Error while registering MBean for SIP %s", esme.getName()), e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 15 with StandardMBean

use of javax.management.StandardMBean in project fabric8 by jboss-fuse.

the class ClusterBootstrapManager method activate.

@Activate
void activate() throws Exception {
    StandardMBean mbean = new StandardMBean(this, ClusterBootstrapManagerMBean.class);
    JMXUtils.registerMBean(mbean, mbeanServer.get(), OBJECT_NAME);
    activateComponent();
}
Also used : StandardMBean(javax.management.StandardMBean) Activate(org.apache.felix.scr.annotations.Activate)

Aggregations

StandardMBean (javax.management.StandardMBean)70 ObjectName (javax.management.ObjectName)32 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)21 MBeanServer (javax.management.MBeanServer)17 MalformedObjectNameException (javax.management.MalformedObjectNameException)16 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)12 MBeanRegistrationException (javax.management.MBeanRegistrationException)9 Test (org.junit.Test)9 JMException (javax.management.JMException)7 IOException (java.io.IOException)6 Logger (org.apache.aries.jmx.Logger)6 InstanceNotFoundException (javax.management.InstanceNotFoundException)5 Activate (org.apache.felix.scr.annotations.Activate)5 IgniteStandardMXBean (org.apache.ignite.internal.mxbean.IgniteStandardMXBean)5 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)5 MBeanInfo (javax.management.MBeanInfo)4 OpenDataException (javax.management.openmbean.OpenDataException)4 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)3 CompositeType (javax.management.openmbean.CompositeType)3 OpenType (javax.management.openmbean.OpenType)3