@Override
 public Integer getMBeanCount() throws IOException {
   try {
     return connection.getMBeanCount();
   } catch (IOException e) {
     checkConnection();
     return connection.getMBeanCount();
   }
 }
Example #2
0
  public static void main(String[] args) throws Exception {
    // Get a connection to the JBoss AS MBean server on localhost
    String host = "localhost";
    int port = 1090;
    String urlString =
        System.getProperty(
            "jmx.service.url", "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi");
    JMXServiceURL serviceURL = new JMXServiceURL(urlString);
    JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null);
    MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();

    // Invoke on the JBoss AS MBean server
    int count = connection.getMBeanCount();
    System.out.println(count);
  }