JBoss AS 7 提供不同的管理界面。所有基于 Detyped Management 表示 (jboss-dmr) 的管理接口。
您可以使用 jboss-dmr 库和 jboss-as-controller-client 实现自定义 Java 客户端。例如,请参阅我们的github 存储库。
要获取有关 JVM 和其他内容的信息,您需要实现以下操作:
ModelNode operation = new ModelNode();
operation.get("operation").set("read-resource");
operation.get("recursive").set(true);
operation.get("include-runtime").set(true);
ModelNode address = operation.get("address");
address.add("core-service", "platform-mbean");
或者,您也可以使用 PlatformMBeanServer:
//Get a connection to the JBoss AS MBean server on localhost
String host = "localhost";
int port = 9999; // management-native port
String urlString = "service:jmx:remoting-jmx://" + host + ":" + port;
JMXServiceURL serviceURL = new JMXServiceURL(urlString);
JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null);
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
//Invoke on the JBoss AS MBean server
connection.getObjectInstance(new ObjectName("java.lang:type=Threading"));
//...
jmxConnector.close();