-
1. Re: Calling a MBean from the server side.
thammoud Apr 20, 2004 3:38 PM (in response to sturiot)This is what we do and it works well for us.
public static Object getMBean(String name) {
try {
ObjectName myBeanContainerName = new ObjectName(name);
Object myParams[] = { myBeanContainerName };
String mySig[] = {"javax.management.ObjectName"};
MBeanServer myServer = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
MBeanEntry myContainerEntry = (MBeanEntry)myServer.invoke(new ObjectName("JMImplementation:type=MBeanRegistry"),
"get",
myParams,
mySig);
mbean = myContainerEntry.getResourceInstance();
// Handle XMBeans
if (mbean instanceof XMBean) {
XMBean xmBean = (XMBean)mbean;
mbean = xmBean.getResource();
}
return mbean;
}
catch(Throwable e) {
throw new RuntimeException(e);
}
} -
2. Re: Calling a MBean from the server side.
guy_rouillier Apr 22, 2004 5:01 PM (in response to sturiot)Why is all that necessary? If all you want to do is invoke an MBean from within an EJB or another MBean, you can just do a simple lookup on the MBean, right?