Standard MBeans are ideally suited for straightforward management structures, where the structure of managed data is well defined in advance and unlikely to change often. In such cases, standard MBeans provide the quickest and easiest way to instrument manageable resources. When the data structures are likely to evolve often over time, the instrumentation must provide more flexibility, such as being determined dynamically at runtime. Dynamic MBeans bring this adaptability to the JMX specification and provide an alternative instrumentation with more elaborate management capabilities.
Dynamic MBeans are resources that are instrumented through a predefined a interface that exposes the attributes and operations only at runtime. Instead of exposing them directly through method names, dynamic MBeans implement a method that returns all attributes and operation signatures. For example, this information could be determined by reading an XML file at runtime.
Because the names of attribute and operations are determined by dynamically, these MBeans provide great flexibility when instrumenting existing resources. An MBean that implements the DynamicMBean interface provides a mapping for existing resource that do not follow standard MBean design patterns. Instead of introspection, JMX agents call the method of the MBean that returns the name of the attributes and operations it exposes.
When managed through a JMX agent, dynamic MBeans offer all same capabilities that are available through standard MBeans. Management application that rely on JMX agent can manipulate all MBeans in exactly the same manner regardless of their type.
DynamicMBean Interface
For a resource object to be recognized as a dynamic MBean by the JMX agent, its Java class or one of its superclasses must implement the DynamicMBean public interface.
Each of methods defined in DynamicMBean interface is described in the following subsections.
getMBeanInfo
This method returns an MBeanInfo object that contains the definition of the MBean's management interface. Conceptually, dynamic MBean have both attributes and operations only they are not exposed through method names. Instead, dynamic MBeans expose attribute names and types operation signatures through the return value of this method at runtime.
本文探讨了Java管理扩展(JMX)中动态MBean与标准MBean的区别及应用场景。标准MBean适用于管理结构固定的情况,而动态MBean则为数据结构经常变化的场景提供了灵活性。动态MBean通过运行时确定属性和操作,使其能够更好地适应资源的变化。

被折叠的 条评论
为什么被折叠?



