I have been searching the web for a while now trying to figure out a way to expose attributes using a model mbean withOUT also exposing the getters and/or setters of these attributes as operations. First off, it seems to me to be a bug in the JMX spec that when creating a ModelMBeanInfo object (for example, using an ModelMBeanInfoSupport), that each ModelMBeanAttributeInfo must also have corresponding ModelMBeanOperations for the getters and setters. Why the need for the duplication of effort and data? Furthermore, all JMX clients I've used (namely jconsole and jmanage) then show all those redundant getters and setters in the interface, completely cluttering up the list of operations (especially if there are a lot of attributes).
Has anyone been able to work around this while still using model mbeans? I've seen a bunch of posters to other forums with this problem (for example, see http://forum.springframework.org/archive/index.php/t-25943.html on the spring JMX forums), but no good solutions.
Re: Flaw in the way Model MBeans expose attributes.
Feb 12, 2007 1:51 AM
(reply 2
of 5) (In reply to
#1 )
Hi,
Yes, this is a known oddity in the ModelMBean specification.
You may be interested in the article I have written about DynamicMBeans,
ModelMBeans, and Pojos...
<http://blogs.sun.com/jmxetc/entry/dynamicmbeans%2C_modelmbeans%2C_and_pojos...>
Cheers,
-- daniel
JMX, SNMP, Java, etc...
http://blogs.sun.com/jmxetc
Hi Daniel.
I faced an issue seems be very close to the thread subj.
I have a Mbean exposed as ModelMBean. One of its attributes is defined as write only:
Re: Flaw in the way Model MBeans expose attributes.
Aug 14, 2007 3:39 AM
(reply 5
of 5) (In reply to
#4 )
Hi,
If you're connecting with JConsole, the tool is going to try to get the value of all
attributes to display them, without checking whether some of them are write-only.
I think this is the reason for the log message you're observing.
With JDK 6 this results in a "SEVERE" message being spit out.
In JDK 7 it's a simple "WARNING" - though now that I think of it, it could
reasonably be downgraded to a simple "FINE/FINER" debug trace.
Standard MBean do not print any WARNING in this case so there's no reason
that RequiredModelMBean should.
I have logged
6592586 RequiredModelMBean prints a WARNING message when calling getAttributes() for a non-existing attr
to track this.