JMX monitor / notification / attribute and my own object
Hi,
I m beginning in JMX,
In all exemples I found, it s always simple type (int String ...)
1)What object can be supervised?
Can i have a Mbean like :
MyMbean{
mycompagny.datas.MyObject o;
public mycompagny.datas.MyObject getX(){return o}
public void setX(mycompagny.datas.MyObject o ){this.o = o}
}
2)In notification, can i put a mycompagny.datas.MyObject inside (i need my jar on manager side so?)
Thanks
(sorry for my english)
[512 byte] By [
jadtna] at [2007-10-3 4:28:01]

Hi,
The short answer is yes to all your questions.
The longer answer is that you should be careful when using custom types
in your MBeans, because 1) you will need to make them serializable, and
take care of compatibility issues when they evolve, and 2) you will need to
make the jar that contain them available on the manager side.
To overcome this, JMX defines the notion of Open MBeans and OpenTypes, that
is, generic data-types (CompositeData and TabularData) that can be used to
model custom types.
In JDK 6, we're also introducing the notion of MXBean (see the excellent article
on http://java.sun.com/developer/technicalArticles/J2SE/mxbeans/ ).
MXBeans are just like MBeans, except that the MBeanServer will automatically
transform your custom types into OpenTypes (not all custom types can be
automatically converted - but a great many of them).
In JDK 6 build 98 you will find a new advanced JMX example that demonstrate
configuration MXBeans using XML serializable beans as MBean attributes.
Concerning Notifications, the same concerns applies. We usually recommend
not to create any custom subclass of notification, but use one of the standard
base classes instead. A JMX notification has a user data field in which you
could embed an instance of a generic Open Type (CompositeData/TabularData)
if needed.
The new advanced JMX example also show how you can 'reuse' the base
notification classes.
See:
http://blogs.sun.com/jmxetc/entry/looking_for_jmx_overview_examples
for JMX tutorial, examples, etc...
and
http://blogs.sun.com/jmxetc/entry/an_advanced_jmx_example_for
for instruction on the new JDK 6 JMX example.
I hope this will get you started on JMX!
-- daniel
JMX, SNMP, Java, etc
http://blogs.sun.com/jmxetc