Spring ManagedAttribute appears in the Operations tab of the JMX console

百般思念 提交于 2019-12-10 22:55:13

问题


My MBeans are annotated using Spring annotations as follows:

@ManagedAttribute(description = "returns the name")
    public String getName() {
        return name;
    }

Now, whenever I open a JMX Console (be it VisualVM or JConsole), I can see the attributes of my beans in the Attributes tab, but I can also see the getName() method exposed in the Operations tab. Is there a way in which I can only see the attribute in the Attribute tab (i.e. hide it from the Operations tab)?


回答1:


AbstractReflectiveMBeanInfoAssembler has this code since 2008:

// Attributes need to have their methods exposed as
// operations to the JMX server as well.

If you see the descriptor part of the javax.management.modelmbean.ModelMBeanOperationInfo, you'll see that there are parameters role=getter and visibility=4, which should (it depends on application that displays attributes/operations) be hidden somehow.

See more details under https://jira.spring.io/browse/SPR-4232.



来源:https://stackoverflow.com/questions/33241311/spring-managedattribute-appears-in-the-operations-tab-of-the-jmx-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!