私のクラスが内部クラスであるという事実が問題を引き起こしているようです、それは私の予感です-しかし基本的にそれは通常のパターンです:
public class UserProvisionerProfiler implements UserProvisionerProfilerMBean {
@Override
public int getTotalNumberOfUsers() {
return activeClients.size();
}
}
そして、インターフェース(より大きなクラスにネストされています):
public interface UserProvisionerProfilerMBean {
public int getTotalNumberOfUsers();
}
コードに登録:
UserProvisionerProfiler userProvisionerProfiler = new UserProvisionerProfiler();
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName(userProvisionerProfiler.getClass().getPackage().getName() + ":type=" + userProvisionerProfiler.getClass().getName());
mbs.registerMBean(userProvisionerProfiler, name);
そしてエラー:
1356 [1;31mERROR[39m [main], UserProvisioner ; Unhandled exception caught in main()
javax.management.NotCompliantMBeanException: MBean class UserProvisioner$UserProvisionerProfiler does not implement DynamicMBean, and neither follows the Standard MBean conventions (javax.management.NotCompliantMBeanException: Class UserProvisioner$UserProvisionerProfiler is not a JMX compliant Standard MBean) nor the MXBean conventions (javax.management.NotCompliantMBeanException: UserProvisioner$UserProvisionerProfiler: Class UserProvisioner$UserProvisionerProfiler is not a JMX compliant MXBean)
at com.sun.jmx.mbeanserver.Introspector.checkCompliance(Introspector.java:171)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:317)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:512)
UserProvisioner.registerThisAsMBean(UserProvisioner.java:734)
UserProvisioner.start(UserProvisioner.java:797)
UserProvisioner.main(UserProvisioner.java:844)
JMXの仕様やコードを読む以外に、準拠したMBeanのより厳密な定義を見つけることにほとんど成功していません。そのため、内部クラスを回収できるのか、それとも分離する必要があるのか、それとも何かあるのか疑問に思います。そうでなければ私は行方不明です。