This is not a tag line!
Accessing a JMX object programmatically from JBoss
OK so here’s some geeky information… I’ve had several times the need to access a JMX service programmatically and each time, I had to hunt down the information so here it is so that I know where to find it next time.
It took me three years almost to the days to need that piece of code again and realize that it wouldn’t even compile… Should be fixed now!
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanProxyCreationException;
import org.jboss.mx.util.MBeanServerLocator;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
ObjectName objectName;
String name;
try {
objectName = new ObjectName(name);
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException("'" + name + "' is not a valid ObjectName");
}
MBeanServer server = MBeanServerLocator.locateJBoss();
try {
return MBeanProxy.get(clazz, objectName, server);
} catch (MBeanProxyCreationException e) {
String message = "Couldn't retrieve '" + objectName.getCanonicalName() + "' MBean with class " + clazz.getName();
throw new RuntimeException(message, e);
}
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
| Print article | This entry was posted by Chris on April 15, 2006 at 01:28, and is filed under jboss. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |
Comments are closed.
