Search in sources :

Example 51 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project geode by apache.

the class MBeanJMXAdapter method registerMBean.

/**
   * This method will register an MBean in GemFire domain. Even if the client provides a domain name
   * it will be ignored and GemFire domain name will be used.
   * 
   * This method checks the local Filter for registering the MBean. If filtered the MBean wont be
   * registered. Although the filter will remember the filtered MBean and register it once the
   * filter is removed.
   * 
   * @param object
   * @param objectName
   * @return modifed ObjectName
   */
public ObjectName registerMBean(Object object, ObjectName objectName, boolean isGemFireMBean) {
    ObjectName newObjectName = objectName;
    try {
        if (!isGemFireMBean) {
            String member = getMemberNameOrId(distMember);
            String objectKeyProperty = objectName.getKeyPropertyListString();
            newObjectName = ObjectName.getInstance(OBJECTNAME__PREFIX + objectKeyProperty + KEYVAL_SEPARATOR + "member=" + member);
        }
        mbeanServer.registerMBean(object, newObjectName);
        this.localGemFireMBean.put(newObjectName, object);
    } catch (InstanceAlreadyExistsException e) {
        throw new ManagementException(e);
    } catch (MBeanRegistrationException e) {
        throw new ManagementException(e);
    } catch (NotCompliantMBeanException e) {
        throw new ManagementException(e);
    } catch (MalformedObjectNameException e) {
        throw new ManagementException(e);
    } catch (NullPointerException e) {
        throw new ManagementException(e);
    }
    return newObjectName;
}
Also used : ManagementException(org.apache.geode.management.ManagementException) MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 52 with NotCompliantMBeanException

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

the class NotCompliantCauseTest method test1.

/**
     * Test that NotCompliantMBeanException has a cause in case of
     * type mapping problems.
     **/
void test1() {
    try {
        MBeanServer mbs = MBeanServerFactory.createMBeanServer();
        ObjectName oname = new ObjectName("domain:type=test");
        mbs.createMBean(NotCompliant.class.getName(), oname);
        System.err.println("ERROR: expected " + "NotCompliantMBeanException not thrown");
        throw new RuntimeTestException("NotCompliantMBeanException not thrown");
    } catch (RuntimeTestException e) {
        throw e;
    } catch (NotCompliantMBeanException e) {
        Throwable cause = e.getCause();
        if (cause == null)
            throw new RuntimeTestException("NotCompliantMBeanException " + "doesn't have any cause.", e);
        while (cause.getCause() != null) {
            if (cause instanceof OpenDataException)
                break;
            cause = cause.getCause();
        }
        if (!(cause instanceof OpenDataException))
            throw new RuntimeTestException("NotCompliantMBeanException " + "doesn't have expected cause (" + OpenDataException.class.getName() + "): " + cause, e);
        System.err.println("SUCCESS: Found expected cause: " + cause);
    } catch (Exception e) {
        System.err.println("Unexpected exception: " + e);
        throw new RuntimeException("Unexpected exception: " + e, e);
    }
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) OpenDataException(javax.management.openmbean.OpenDataException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 53 with NotCompliantMBeanException

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

the class GetMBeanInfoExceptionTest method main.

public static void main(String[] args) throws Exception {
    int error = 0;
    // Instantiate the MBean server
    //
    System.out.println("Create the MBean server");
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    // Register the MBean
    //
    System.out.println("Create a TestDynamicMBean");
    TestDynamicMBean obj = new TestDynamicMBean();
    ObjectName n = new ObjectName("d:k=v");
    try {
        mbs.registerMBean(obj, n);
        System.out.println("Didn't get expected NotCompliantMBeanException");
        error++;
    } catch (NotCompliantMBeanException e) {
        boolean found = false;
        Throwable t = e.getCause();
        while (t != null) {
            if (t instanceof IllegalArgumentException && "GetMBeanInfoExceptionTest".equals(t.getMessage())) {
                found = true;
            }
            t = t.getCause();
        }
        if (found) {
            System.out.println("Found expected IllegalArgumentException");
        } else {
            System.out.println("Didn't find expected IllegalArgumentException");
            error++;
        }
    } catch (Exception e) {
        System.out.println("Got " + e.getClass().getName() + "instead of expected NotCompliantMBeanException");
        error++;
    }
    if (error > 0) {
        System.out.println("Test failed");
        throw new IllegalArgumentException("Test failed");
    } else {
        System.out.println("Test passed");
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) AttributeNotFoundException(javax.management.AttributeNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) ReflectionException(javax.management.ReflectionException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 54 with NotCompliantMBeanException

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

the class MBeanFallbackTest method testPrivate.

private static void testPrivate(Class<?> iface, Object bean) throws Exception {
    try {
        System.out.println("Registering a private MBean " + iface.getName() + " ...");
        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Compliant");
        mbs.registerMBean(bean, on);
        success("Registered a private MBean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("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 55 with NotCompliantMBeanException

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

the class MBeanTest method testCompliant.

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