Я пытаюсь получить экземпляр класса обслуживания, связанный с 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, а также мы можем получить атрибуты, по которым мы можем создать экземпляр.Есть ли лучший способ сделать это?