本文整理匯總了Java中javax.management.RuntimeMBeanException類的典型用法代碼示例。如果您正苦於以下問題:Java RuntimeMBeanException類的具體用法?Java RuntimeMBeanException怎麽用?Java RuntimeMBeanException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RuntimeMBeanException類屬於javax.management包,在下文中一共展示了RuntimeMBeanException類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: throwMBeanRegistrationException
import javax.management.RuntimeMBeanException; //導入依賴的package包/類
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
if (t instanceof RuntimeException) {
throw new RuntimeMBeanException((RuntimeException)t,
"RuntimeException thrown " + where);
} else if (t instanceof Error) {
throw new RuntimeErrorException((Error)t,
"Error thrown " + where);
} else if (t instanceof MBeanRegistrationException) {
throw (MBeanRegistrationException)t;
} else if (t instanceof Exception) {
throw new MBeanRegistrationException((Exception)t,
"Exception thrown " + where);
} else // neither Error nor Exception??
throw new RuntimeException(t);
}
示例2: postRegister
import javax.management.RuntimeMBeanException; //導入依賴的package包/類
private static void postRegister(
ObjectName logicalName, DynamicMBean mbean,
boolean registrationDone, boolean registerFailed) {
if (registerFailed && mbean instanceof DynamicMBean2)
((DynamicMBean2) mbean).registerFailed();
try {
if (mbean instanceof MBeanRegistration)
((MBeanRegistration) mbean).postRegister(registrationDone);
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Exception thrown by postRegister: " +
"rethrowing <"+e+">, but keeping the MBean registered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postRegister method: "+
"rethrowing <"+e+">, but keeping the MBean registered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Error thrown by postRegister: " +
"rethrowing <"+er+">, but keeping the MBean registered");
throw new RuntimeErrorException(er,
"Error thrown in postRegister method: "+
"rethrowing <"+er+">, but keeping the MBean registered");
}
}
示例3: postDeregisterInvoke
import javax.management.RuntimeMBeanException; //導入依賴的package包/類
private static void postDeregisterInvoke(ObjectName mbean,
MBeanRegistration moi) {
try {
moi.postDeregister();
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Exception thrown by postDeregister: " +
"rethrowing <"+e+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postDeregister method: "+
"rethrowing <"+e+
">, although the MBean is sucessfully unregistered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Error thrown by postDeregister: " +
"rethrowing <"+er+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeErrorException(er,
"Error thrown in postDeregister method: "+
"rethrowing <"+er+
">, although the MBean is sucessfully unregistered");
}
}
示例4: postRegister
import javax.management.RuntimeMBeanException; //導入依賴的package包/類
private static void postRegister(
ObjectName logicalName, DynamicMBean mbean,
boolean registrationDone, boolean registerFailed) {
if (registerFailed && mbean instanceof DynamicMBean2)
((DynamicMBean2) mbean).registerFailed();
try {
if (mbean instanceof MBeanRegistration)
((MBeanRegistration) mbean).postRegister(registrationDone);
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.log(Level.DEBUG, "While registering MBean ["+logicalName+
"]: " + "Exception thrown by postRegister: " +
"rethrowing <"+e+">, but keeping the MBean registered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postRegister method: "+
"rethrowing <"+e+">, but keeping the MBean registered");
} catch (Error er) {
MBEANSERVER_LOGGER.log(Level.DEBUG, "While registering MBean ["+logicalName+
"]: " + "Error thrown by postRegister: " +
"rethrowing <"+er+">, but keeping the MBean registered");
throw new RuntimeErrorException(er,
"Error thrown in postRegister method: "+
"rethrowing <"+er+">, but keeping the MBean registered");
}
}
示例5: postDeregisterInvoke
import javax.management.RuntimeMBeanException; //導入依賴的package包/類
private static void postDeregisterInvoke(ObjectName mbean,
MBeanRegistration moi) {
try {
moi.postDeregister();
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.log(Level.DEBUG, "While unregistering MBean ["+mbean+
"]: " + "Exception thrown by postDeregister: " +
"rethrowing <"+e+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postDeregister method: "+
"rethrowing <"+e+
">, although the MBean is sucessfully unregistered");
} catch (Error er) {
MBEANSERVER_LOGGER.log(Level.DEBUG, "While unregistering MBean ["+mbean+
"]: " + "Error thrown by postDeregister: " +
"rethrowing <"+er+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeErrorException(er,
"Error thrown in postDeregister method: "+
"rethrowing <"+er+
">, although the MBean is sucessfully unregistered");
}
}
示例6: rethrowCause
import javax.management.RuntimeMBeanException; //導入依賴的package包/類
/**
* Expand inner exception wrapped by JMX.
*
* @param innerObject
* jmx proxy which will be wrapped and returned
*/
protected <T> T rethrowCause(final T innerObject) {
@SuppressWarnings("unchecked")
final T proxy = (T) Proxy.newProxyInstance(innerObject.getClass().getClassLoader(),
innerObject.getClass().getInterfaces(), (proxy1, method, args) -> {
try {
return method.invoke(innerObject, args);
} catch (final InvocationTargetException e) {
try {
throw e.getTargetException();
} catch (final RuntimeMBeanException e2) {
throw e2.getTargetException();
}
}
});
return proxy;
}
示例7: testAddressControl
import javax.management.RuntimeMBeanException; //導入依賴的package包/類
@Test
@BMRules(
rules = {@BMRule(
name = "checking ActiveMQServerControl methods",
targetClass = "org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl",
targetMethod = "route(org.apache.activemq.artemis.api.core.Message, boolean)",
targetLocation = "ENTRY",
action = "throw new org.apache.activemq.artemis.api.core.ActiveMQException(\"gotcha\")")})
public void testAddressControl() throws Exception {
server.getActiveMQServerControl().createAddress("test.address", "ANYCAST");
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
System.out.println("server is " + mbs);
ObjectName objectName = new ObjectName("org.apache.activemq.artemis:broker=\"localhost\",component=addresses,address=\"test.address\"");
Object[] params = new Object[] {new HashMap(), 3, "aGVsbG8=", true, null, null};
String[] signature = new String[] {"java.util.Map", "int", "java.lang.String", "boolean", "java.lang.String", "java.lang.String"};
try {
mbs.invoke(objectName, "sendMessage", params, signature);
fail("test should have gotten an exception!");
} catch (RuntimeMBeanException ex) {
assertTrue(ex.getCause() instanceof IllegalStateException);
IllegalStateException e = (IllegalStateException) ex.getCause();
assertEquals("gotcha", e.getMessage());
}
}