It is like you want to see all MBeans that exist anywhere, but you cannot, because the code does not create them all at once.
I suggest using a code generator that creates an โappearanceโ of MBeans for all real MBeans. For example, use the class or marker interface to search for MBeans. The beans view must be created at startup.
Now that a real MBean appears, he needs to look at his presentation and hook himself.
Thus, all MBeans will always be visible, the launch will not suffer much (since the presentation of MBeans will be really cheap), and the view of MBeans can tell you the status of real MBeans.
[EDIT] If you really need to know when a new MBean is registered, expand the existing MBeanServer and override registerMBean(Object, ObjectName) . Install the new MBeanServer by setting the System property javax.management.builder.initial .
Now identify the MBean that provides this information.
Aaron digulla
source share