-
-
2. Re: How many EJBs deployed in JBoss
stefus Oct 1, 2002 5:27 AM (in response to stefus)How can I do this from a Java Client. Have someone any code snippet for me.
Regards
Stefan -
3. Re: How many EJBs deployed in JBoss
adrian.brock Oct 1, 2002 8:22 AM (in response to stefus)You'll needs some jars from ${jboss.dist}/client
import java.util.*;
import javax.management.*;
import javax.naming.*;
import org.jboss.jmx.adaptor.rmi.*;
import org.jboss.jmx.connector.*;
import org.jboss.jmx.connector.rmi.*;
public class Client
{
public static void main(String[] args)
throws Exception
{
// Set up jndi properties
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext ctx = new InitialContext(props);
// Retrieve the RMI adaptor
Object obj = ctx.lookup("jmx:local:rmi");
ctx.close();
// Wrap it in a connector
RemoteMBeanServer server = new RMIConnectorImpl((RMIAdaptor)obj);
// Print the EJB count
System.out.println(server.queryMBeans(new ObjectName("jboss.j2ee:service=EJB,*"), null).size());
}
}