Search in sources :

Example 6 with StandardMBean

use of javax.management.StandardMBean in project jdk8u_jdk by JetBrains.

the class TooManyFooTest method main.

public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child, "Child[MBean]", false);
    final ChildMix childx = new ChildMix();
    test(childx, "ChildMix[MXBean]", true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx, "ChildMixMix[MXBean]", false);
    final StandardMBean schild = new StandardMBean(child, ChildMBean.class);
    test(schild, "Child[StandarMBean(Child)]", false);
    final StandardMBean schildx = new StandardMBean(childx, ChildMXBean.class, true);
    test(schildx, "ChildMix[StandarMXBean(ChildMix)]", true);
    final StandardMBean schildmx = new StandardMBean(childmx, ChildMixMXBean.class, true);
    test(schildmx, "ChildMixMix[StandarMXBean(ChildMixMix)]", true);
}
Also used : StandardMBean(javax.management.StandardMBean)

Example 7 with StandardMBean

use of javax.management.StandardMBean in project jdk8u_jdk by JetBrains.

the class ServerDelegate method createStandardMBean.

/**
     * Instantiates and registers a StandardMBean in the MBean server.
     *
     * @param implementationClassName
     *      The implementation class name of the MBean.
     * @param interfaceClassName
     *      The management interface class name of the MBean.
     * @param isMXBean
     *      If true, the resultant MBean is an MXBean.
     * @param name
     *      The object name of the StandardMBean.
     */
@SuppressWarnings("unchecked")
public void createStandardMBean(String implementationClassName, String interfaceClassName, boolean isMXBean, ObjectName name) throws Exception {
    Object implementation = Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null : (Class<Object>) Class.forName(interfaceClassName);
    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(implementation, interfaceClass, isMXBean);
    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
Also used : StandardMBean(javax.management.StandardMBean)

Example 8 with StandardMBean

use of javax.management.StandardMBean in project ddf by codice.

the class SolrCache method configureMBean.

private void configureMBean() {
    LOGGER.debug("Registering Cache Manager Service MBean");
    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
    try {
        objectName = new ObjectName(SolrCacheMBean.OBJECTNAME);
    } catch (MalformedObjectNameException e) {
        LOGGER.info("Could not create object name", e);
    }
    try {
        try {
            mbeanServer.registerMBean(new StandardMBean(this, SolrCacheMBean.class), objectName);
        } catch (InstanceAlreadyExistsException e) {
            LOGGER.debug("Re-registering Cache Manager MBean");
            mbeanServer.unregisterMBean(objectName);
            mbeanServer.registerMBean(new StandardMBean(this, SolrCacheMBean.class), objectName);
        }
    } catch (Exception e) {
        LOGGER.debug("Could not register MBean.", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) SolrCacheMBean(ddf.catalog.cache.SolrCacheMBean) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) MetacardCreationException(ddf.catalog.data.MetacardCreationException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SolrException(org.apache.solr.common.SolrException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) IOException(java.io.IOException) MalformedObjectNameException(javax.management.MalformedObjectNameException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 9 with StandardMBean

use of javax.management.StandardMBean in project jdk8u_jdk by JetBrains.

the class OldMBeanServerTest method testJavaxManagementStandardMBean.

private static void testJavaxManagementStandardMBean() throws Exception {
    ObjectName name = new ObjectName("a:b=c");
    Object mbean = new StandardMBean(new Boring(), BoringMBean.class);
    mbsc.createMBean(StandardMBean.class.getName(), name, new Object[] { new Boring(), BoringMBean.class }, new String[] { Object.class.getName(), Class.class.getName() });
    assert mbsc.getAttribute(name, "Name").equals("Jessica");
    assert mbsc.invoke(name, "add", new Object[] { 2, 3 }, new String[] { "int", "int" }).equals(5);
    mbsc.unregisterMBean(name);
}
Also used : StandardMBean(javax.management.StandardMBean) AccessibleObject(java.lang.reflect.AccessibleObject) ObjectName(javax.management.ObjectName)

Example 10 with StandardMBean

use of javax.management.StandardMBean in project drools by kiegroup.

the class DroolsManagementAgent method registerMBean.

public void registerMBean(Object owner, Object mbean, ObjectName name) {
    try {
        MBeanServer mbs = getMBeanServer();
        if (!mbs.isRegistered(name)) {
            mbs.registerMBean(mbean, name);
            List<ObjectName> mbl = mbeans.get(owner);
            if (mbl == null) {
                mbl = new LinkedList<ObjectName>();
                mbeans.put(owner, mbl);
                if (mbean instanceof StandardMBean) {
                    mbeansRefs.put(owner, ((StandardMBean) mbean).getImplementation());
                } else {
                    mbeansRefs.put(owner, mbean);
                }
            }
            mbl.add(name);
            logger.debug("Registered {} into the platform MBean Server", name);
        }
    } catch (Exception e) {
        logger.error("Unable to register mbean " + name + " into the platform MBean Server", e);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

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