【问题标题】:How to Show Class Description, Attribute descriptions and Operation Descriptions of jmx MBeans如何显示jmx MBean的类描述、属性描述和操作描述
【发布时间】:2013-02-21 17:51:37
【问题描述】:
我创建了一些实现接口的 bean,并创建了一个自定义的 MBean 导出器以将这些 bean 公开给 jconsole。
尽管一切正常,但描述未正确显示。
在 bean 的顶部我看到:
Java 类:$Proxy483
描述:MBean的管理接口信息
以及我看到的属性和操作的描述:
为管理公开的操作
有什么办法可以看到我在@ManagedResource注解中设置的描述?
提前致谢
【问题讨论】:
标签:
java
spring
jboss7.x
jmx
mbeans
【解决方案1】:
您的 MBeanExporter 需要一个 JmxAttributeSource 实现(没有默认值)。 Springreference 提供以下示例:
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="assembler" ref="assembler"/>
<property name="namingStrategy" ref="namingStrategy"/>
<property name="autodetect" value="true"/>
</bean>
<!-- Implementation of the JmxAttributeSource interface that reads JDK 1.5+ annotations and exposes the corresponding attributes -->
<bean id="jmxAttributeSource" class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/>
<!-- will create management interface using annotation metadata -->
<bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
<property name="attributeSource" ref="jmxAttributeSource"/>
</bean>
<!-- will pick up the ObjectName from the annotation -->
<bean id="namingStrategy" class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
<property name="attributeSource" ref="jmxAttributeSource"/>
</bean>
【解决方案2】:
您是否尝试提供对象名称和描述?
@ManagedResource(
objectName="org.springbyexample.jmx:name=ServerManager",
description="Server manager."
)