一次性MBean

时间:2013-03-23 10:21:11

标签: java

我怎样才能实现一次性MBean,它不会阻止它监控的资源被垃圾收集? 假设我编写了虚拟统计MBean,但它监视的类不是系统中的单例。一旦资源不再使用,我希望MBean能够自动取消注册。

任何想法如何实现? 任何现有的解决方案?

感谢。

1 个答案:

答案 0 :(得分:0)

用法

$ g++ --version
g++ (Debian 5.3.1-14) 5.3.1 20160409
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Implementatin

Score enumertions
registerWeakMBean("com.company:type=connection,name=" +
getClass().getSimpleName(), connectionStatMBeanImpl, ConnectionStatMBean.class);