我的 MBean 使用 Spring 注释进行注释,如下所示:
@ManagedAttribute(description = "returns the name")
public String getName() {
return name;
}
现在,每当我打开 JMX 控制台(无论是 VisualVM 还是 JConsole)时,我都可以在“属性”选项卡中看到 bean 的属性,而且还可以看到“操作”选项卡中公开的 getName() 方法。有没有办法让我只能在“属性”选项卡中看到该属性(即从“操作”选项卡中隐藏它)?
最佳答案
AbstractReflectiveMBeanInfoAssembler自 2008 年起就有此代码:
// Attributes need to have their methods exposed as
// operations to the JMX server as well.
如果您看到 javax.management.modelmbean.ModelMBeanOperationInfo
的描述符部分,您将看到参数 role=getter
和 visibility= 4
,它应该(取决于显示属性/操作的应用程序)以某种方式隐藏。
查看 https://jira.spring.io/browse/SPR-4232 下的更多详细信息.
关于jmx - Spring ManagedAttribute 显示在 JMX 控制台的“操作”选项卡中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33241311/