我正在尝试jboss-service.xml
使用 MBean 获取绑定的服务类的实例。
JBoss-Service.xml
已经定义了BasicThreadPool
我们想在我们的代码中使用它。这就是它的所在JBOSS-Service.xml
。
<mbean
code="org.jboss.util.threadpool.BasicThreadPool"
name="jboss.system:service=ThreadPool">
<attribute name="Name">JBoss System Threads</attribute>
<attribute name="ThreadGroupName">System Threads</attribute>
<attribute name="KeepAliveTime">60000</attribute>
<attribute name="MaximumPoolSize">10</attribute>
<attribute name="MaximumQueueSize">1000</attribute>
<!-- The behavior of the pool when a task is added and the queue is full.
abort - a RuntimeException is thrown
run - the calling thread executes the task
wait - the calling thread blocks until the queue has room
discard - the task is silently discarded without being run
discardOldest - check to see if a task is about to complete and enque
the new task if possible, else run the task in the calling thread
-->
<attribute name="BlockingMode">run</attribute>
</mbean>
我正在尝试在我的代码中访问它,如下所示,
MBeanServer server = MBeanServerLocator.locateJBoss();
MBeanInfo mbeaninfo = server.getMBeanInfo(new ObjectName("jboss.system:service=ThreadPool"));
现在我有了 MBean 信息。我想要一个BasicThreadPool
在 MBean 中定义的对象的实例。可能吗 ?
我知道一种方法,我们可以从 MBean Info 中获取类名,也可以获取构造实例的属性。有没有更好的方法呢?