[jboss-user] [Management, JMX/JBoss] - Re: Listing all EJBs through JMX
danieldestro
do-not-reply at jboss.com
Fri Jan 12 08:10:10 EST 2007
Finally I achieved what I wanted.
The code bellow shows all the "ejb-jar.xml" deployed in the container.
package test;
|
| import java.lang.reflect.Method;
| import java.util.*;
| import javax.management.*;
| import org.jboss.jmx.adaptor.control.*;
| import org.jboss.mx.server.*;
| import org.jboss.mx.util.*;
|
| public class Test {
| public void getDeploymentDescriptors() {
| String query = "jboss.management.local:*,j2eeType=EJBModule";
| MBeanServer server = (MBeanServer) MBeanServerLocator.locateJBoss();
| Set matches = server.queryMBeans( new ObjectName( query ), null );
| Iterator it = matches.iterator();
| while( it.hasNext() ) {
| ObjectInstance soi = (ServerObjectInstance) it.next();
| ObjectName objName = soi.getObjectName();
|
| String objectNameString = objName.toString();
| MBeanInfo mbeanInfo = server.getMBeanInfo(objName);
| MBeanAttributeInfo[] attributeInfo = mbeanInfo.getAttributes();
|
| for( int a=0; a < attributeInfo.length; a++ ) {
| MBeanAttributeInfo attrInfo = attributeInfo[a];
| if( !"deploymentDescriptor".equals( attrInfo.getName() ) ) {
| continue;
| }
| AttrResultInfo attrResult = Server.getMBeanAttributeResultInfo(objectNameString, attrInfo);
| String attrValue = attrResult.getAsText();
|
| //prints out the "ejb-jar.xml"
| System.out.println( attrValue );
| }
| }
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4000917#4000917
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4000917
More information about the jboss-user
mailing list