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;
}
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);
}
}
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");
}
}
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;
}
}
}
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;
}
}
}
Aggregations