我需要将大约60个操作暴露给JMX,这些操作分布在30个不同的类中。使用DynamicMBean
实现有点麻烦。我正在寻找一种快速而优雅的方法来实现。
我知道Spring有一种很好的注解方式,但是我在这个项目中没有使用Spring。
// you can also use the platform mbean server
JmxServer jmxServer = new JmxServer(8000);
jmxServer.start();
// register our lookupCache object defined below
jmxServer.register(lookupCache);
...
jmxServer.stop();
以下是定义bean的方法。
@JmxResource(domainName = "j256", description = "Lookup cache")
public class LookupCache {
@JmxAttributeField(description = "Number of hits in the cache")
private int hitCount;
...
@JmxOperation(description = "Flush the cache")
public void flushCache() {
...
}
}
欢迎提供反馈。