Search in sources :

Example 56 with NotCompliantMBeanException

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

the class MBeanTest method testNonCompliant.

private static void testNonCompliant(Class<?> iface, Object bean) throws Exception {
    try {
        System.out.println("Registering a non-compliant MBean " + iface.getName() + " ...");
        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=NonCompliant");
        mbs.registerMBean(bean, on);
        fail("Registered a non-compliant MBean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            success("MBean not registered");
        } else {
            throw e;
        }
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 57 with NotCompliantMBeanException

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

the class JMXProxyFallbackTest method testPrivate.

private static void testPrivate(Class<?> iface) throws Exception {
    try {
        System.out.println("Creating a proxy for private M(X)Bean " + iface.getName() + " ...");
        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Proxy");
        JMX.newMBeanProxy(mbs, on, iface);
        success("Created a proxy for private M(X)Bean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("Proxy not created");
        } else {
            throw e;
        }
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 58 with NotCompliantMBeanException

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

the class JMXProxyTest method testCompliant.

private static void testCompliant(Class<?> iface, boolean isMx) throws Exception {
    try {
        System.out.println("Creating a proxy for compliant " + (isMx ? "MXBean" : "MBean") + " " + iface.getName() + " ...");
        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Proxy");
        if (isMx) {
            JMX.newMXBeanProxy(mbs, on, iface);
        } else {
            JMX.newMBeanProxy(mbs, on, iface);
        }
        success("Created a proxy for compliant " + (isMx ? "MXBean" : "MBean") + " - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("Proxy not created");
        } else {
            throw e;
        }
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 59 with NotCompliantMBeanException

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

the class JMXProxyTest method testNonCompliant.

private static void testNonCompliant(Class<?> iface, boolean isMx) throws Exception {
    try {
        System.out.println("Creating a proxy for non-compliant " + (isMx ? "MXBean" : "MBean") + " " + iface.getName() + " ...");
        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Proxy");
        if (isMx) {
            JMX.newMXBeanProxy(mbs, on, iface);
        } else {
            JMX.newMBeanProxy(mbs, on, iface);
        }
        fail("Created a proxy for non-compliant " + (isMx ? "MXBean" : "MBean") + " - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            success("Proxy not created");
        } else {
            throw e;
        }
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 60 with NotCompliantMBeanException

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

the class MXBeanTest method testNonCompliantMXBean.

private static void testNonCompliantMXBean(String type, Object bean) throws Exception {
    System.out.println(type + " MXBean test...");
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    ObjectName on = new ObjectName("test:type=" + type);
    try {
        mbs.registerMBean(bean, on);
        failure(bean.getClass().getInterfaces()[0].getName() + " is not a compliant " + "MXBean interface");
    } catch (NotCompliantMBeanException e) {
        success("Non-compliant MXBean not registered");
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

NotCompliantMBeanException (javax.management.NotCompliantMBeanException)106 ObjectName (javax.management.ObjectName)73 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)71 MBeanRegistrationException (javax.management.MBeanRegistrationException)71 MalformedObjectNameException (javax.management.MalformedObjectNameException)59 MBeanServer (javax.management.MBeanServer)39 InstanceNotFoundException (javax.management.InstanceNotFoundException)23 StandardMBean (javax.management.StandardMBean)20 MBeanException (javax.management.MBeanException)8 ReflectionException (javax.management.ReflectionException)8 IOException (java.io.IOException)7 ObjectInstance (javax.management.ObjectInstance)5 AttributeNotFoundException (javax.management.AttributeNotFoundException)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)4 ListenerNotFoundException (javax.management.ListenerNotFoundException)4 Logger (org.apache.aries.jmx.Logger)4 MalformedURLException (java.net.MalformedURLException)3 DynamicMBean (javax.management.DynamicMBean)3 IntrospectionException (javax.management.IntrospectionException)3 JMRuntimeException (javax.management.JMRuntimeException)3