Reputation: 7380
Is there any way to, without additional libraries, get the MBeanAttributeInfo
of a specific attribute directly, as opposed to using MBeanInfo.getAttributes()
and doing a linear search through it?
Example scenario: check whether a given attribute - jboss:service=Mail.State
in the example - is writable.
MBeanServer server; // Assume this is initialized somewhere else
MBeanAttributeInfo[] infos = server.getMBeanInfo(new ObjectName("jboss:service=Mail"));
for(MBeanAttributeInfo info : infos) {
if(info.getName().equals("State")) {
if(info.isWritable()) {
//do something
}
break;
}
}
What I'm hoping to find is something like a getAttributeInfo(ObjectName name, String attribute)
method in the MBeanServer
.
Upvotes: 0
Views: 894
Reputation:
You can get it by:
server.getAttribute(new ObjectName("jboss:service=Mail"), "State")
where server is a MBeanServerConnection and "State" is the attribute name.
Upvotes: 1