我正在尝试访问部署到 JBOSS AS 7.1.1 中的 MBean 服务。我的 MBean 服务也是一个队列监听器。我正在尝试获取此 MBean 服务的实例以将其注册为另一个 SAR 中的队列侦听器。
我试过这段代码,但它不工作,
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName mbeanObject =
new ObjectName("myproject.service.Test:service=com.mytest.program");
TestServiceMBean handler = MBeanServerInvocationHandler.newProxyInstance(
server, mbeanObject, TestServiceMBean.class, false);
我也试过这个
TestServiceMBean testMBeanService =
(TestServiceMBean)server.getAttribute(mbeanObject, "Instance");
在这两种情况下,我都没有得到TestServiceMBean
. 谁能帮助我获得对 MBean 测试服务的访问权限。
<mbean code="com.mytest.program.TestService"
name="myproject.service.Test:service=com.mytest.program">
</mbean>
这是代码:
public class TestService implements TestServiceMBean, MessageListener {