Search in sources :

Example 1 with DynamicMBean

use of javax.management.DynamicMBean in project ignite by apache.

the class IgniteUtils method registerMBean.

/**
     * Registers MBean with the server.
     *
     * @param <T> Type of mbean.
     * @param mbeanSrv MBean server.
     * @param igniteInstanceName Ignite instance name.
     * @param grp Name of the group.
     * @param name Name of mbean.
     * @param impl MBean implementation.
     * @param itf MBean interface.
     * @return JMX object name.
     * @throws JMException If MBean creation failed.
     */
public static <T> ObjectName registerMBean(MBeanServer mbeanSrv, @Nullable String igniteInstanceName, @Nullable String grp, String name, T impl, @Nullable Class<T> itf) throws JMException {
    assert mbeanSrv != null;
    assert name != null;
    assert itf != null;
    DynamicMBean mbean = new IgniteStandardMXBean(impl, itf);
    mbean.getMBeanInfo();
    return mbeanSrv.registerMBean(mbean, makeMBeanName(igniteInstanceName, grp, name)).getObjectName();
}
Also used : DynamicMBean(javax.management.DynamicMBean) IgniteStandardMXBean(org.apache.ignite.internal.mxbean.IgniteStandardMXBean)

Example 2 with DynamicMBean

use of javax.management.DynamicMBean in project ignite by apache.

the class IgniteUtils method registerCacheMBean.

/**
     * Registers MBean with the server.
     *
     * @param <T> Type of mbean.
     * @param mbeanSrv MBean server.
     * @param igniteInstanceName Ignite instance name.
     * @param cacheName Name of the cache.
     * @param name Name of mbean.
     * @param impl MBean implementation.
     * @param itf MBean interface.
     * @return JMX object name.
     * @throws JMException If MBean creation failed.
     */
public static <T> ObjectName registerCacheMBean(MBeanServer mbeanSrv, @Nullable String igniteInstanceName, @Nullable String cacheName, String name, T impl, Class<T> itf) throws JMException {
    assert mbeanSrv != null;
    assert name != null;
    assert itf != null;
    DynamicMBean mbean = new IgniteStandardMXBean(impl, itf);
    mbean.getMBeanInfo();
    return mbeanSrv.registerMBean(mbean, makeCacheMBeanName(igniteInstanceName, cacheName, name)).getObjectName();
}
Also used : DynamicMBean(javax.management.DynamicMBean) IgniteStandardMXBean(org.apache.ignite.internal.mxbean.IgniteStandardMXBean)

Example 3 with DynamicMBean

use of javax.management.DynamicMBean in project sling by apache.

the class JmxAdjustableStatusForTestingIT method invokeMBean.

private void invokeMBean(String operation, Object[] args, String[] signature) throws Exception {
    ServiceReference[] serviceReference = bundleContext.getServiceReferences(DynamicMBean.class.getName(), "(jmx.objectname=org.apache.sling.healthcheck:type=AdjustableHealthCheckForTesting)");
    DynamicMBean mBean = (DynamicMBean) bundleContext.getService(serviceReference[0]);
    mBean.invoke(operation, args, signature);
}
Also used : DynamicMBean(javax.management.DynamicMBean) ServiceReference(org.osgi.framework.ServiceReference)

Example 4 with DynamicMBean

use of javax.management.DynamicMBean in project spring-framework by spring-projects.

the class JmxUtilsTests method testIsMBeanWithDynamicMBean.

@Test
public void testIsMBeanWithDynamicMBean() throws Exception {
    DynamicMBean mbean = new TestDynamicMBean();
    assertTrue("Dynamic MBean not detected correctly", JmxUtils.isMBean(mbean.getClass()));
}
Also used : DynamicMBean(javax.management.DynamicMBean) TestDynamicMBean(org.springframework.jmx.export.TestDynamicMBean) TestDynamicMBean(org.springframework.jmx.export.TestDynamicMBean) Test(org.junit.Test)

Example 5 with DynamicMBean

use of javax.management.DynamicMBean in project felix by apache.

the class InvokerMBeanServerInterceptor method getAttributes.

public AttributeList getAttributes(MBeanMetaData metadata, String[] attributes) {
    if (metadata.dynamic) {
        try {
            return ((DynamicMBean) metadata.mbean).getAttributes(attributes);
        } catch (JMRuntimeException x) {
            throw x;
        } catch (RuntimeException x) {
            throw new RuntimeMBeanException(x);
        } catch (Error x) {
            throw new RuntimeErrorException(x);
        }
    } else {
        AttributeList list = new AttributeList();
        for (int i = 0; i < attributes.length; ++i) {
            String name = attributes[i];
            try {
                Object value = getAttribute(metadata, name);
                Attribute attr = new Attribute(name, value);
                list.add(attr);
            } catch (Exception ignored) {
                Logger logger = getLogger();
                if (logger.isEnabledFor(Logger.DEBUG))
                    logger.debug("Exception caught from getAttributes(), ignoring attribute " + name);
            }
        }
        return list;
    }
}
Also used : RuntimeMBeanException(javax.management.RuntimeMBeanException) DynamicMBean(javax.management.DynamicMBean) RuntimeErrorException(javax.management.RuntimeErrorException) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) Logger(org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger) AttributeNotFoundException(javax.management.AttributeNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ReflectionException(javax.management.ReflectionException) JMRuntimeException(javax.management.JMRuntimeException) RuntimeMBeanException(javax.management.RuntimeMBeanException) RuntimeErrorException(javax.management.RuntimeErrorException) ImplementationException(org.apache.felix.mosgi.jmx.agent.mx4j.ImplementationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) ListenerNotFoundException(javax.management.ListenerNotFoundException) JMRuntimeException(javax.management.JMRuntimeException) JMRuntimeException(javax.management.JMRuntimeException)

Aggregations

DynamicMBean (javax.management.DynamicMBean)78 MBeanException (javax.management.MBeanException)29 ObjectName (javax.management.ObjectName)24 MalformedObjectNameException (javax.management.MalformedObjectNameException)20 ManagedBean (org.apache.tomcat.util.modeler.ManagedBean)18 RuntimeOperationsException (javax.management.RuntimeOperationsException)16 Test (org.junit.Test)15 AttributeNotFoundException (javax.management.AttributeNotFoundException)14 InstanceNotFoundException (javax.management.InstanceNotFoundException)13 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)13 ListenerNotFoundException (javax.management.ListenerNotFoundException)13 ReflectionException (javax.management.ReflectionException)12 RuntimeErrorException (javax.management.RuntimeErrorException)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 Attribute (javax.management.Attribute)8 JMRuntimeException (javax.management.JMRuntimeException)7 MBeanRegistrationException (javax.management.MBeanRegistrationException)7 NamedObject (com.sun.jmx.mbeanserver.NamedObject)6 Method (java.lang.reflect.Method)6 RuntimeMBeanException (javax.management.RuntimeMBeanException)6