Search in sources :

Example 41 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 42 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 43 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 44 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 45 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)58 ObjectName (javax.management.ObjectName)37 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)29 MBeanRegistrationException (javax.management.MBeanRegistrationException)29 MBeanServer (javax.management.MBeanServer)26 MalformedObjectNameException (javax.management.MalformedObjectNameException)24 StandardMBean (javax.management.StandardMBean)15 InstanceNotFoundException (javax.management.InstanceNotFoundException)9 MBeanException (javax.management.MBeanException)5 ReflectionException (javax.management.ReflectionException)5 AttributeNotFoundException (javax.management.AttributeNotFoundException)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)4 Logger (org.apache.aries.jmx.Logger)4 RegistrableStandardEmitterMBean (org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean)4 IntrospectionException (javax.management.IntrospectionException)3 JMRuntimeException (javax.management.JMRuntimeException)3 ObjectInstance (javax.management.ObjectInstance)3 RuntimeOperationsException (javax.management.RuntimeOperationsException)3 PackageAdmin (org.osgi.service.packageadmin.PackageAdmin)3 IOException (java.io.IOException)2