问题
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