// In fact, you need to get MBeanServerConnection reference firstly, based on your application, there are 2 way:
MBeanServerConnection connection = null;
// 1. If you are developing a MBean which will be deployed into JBoss.
connection = MBeanServerLocator.locateJBoss();
// 2. If you are developing a stand-alone application.
InitialContext context = new InitialContext();
connection = (MBeanServerConnection) context.lookup("jmx/invoker/RMIAdaptor");
// Then, after you got the reference, just call JMX.newMBeanProxy.
MyMBean myMBan = (MyMBean) JMX.newMBeanProxy(connection, new ObjectName( "My MBean name"), MyMBean.class);
本文介绍了两种获取MBeanServerConnection的方法:一种是在JBoss环境中部署MBean时使用MBeanServerLocator;另一种是在独立应用程序中通过InitialContext进行查找。
130

被折叠的 条评论
为什么被折叠?



