File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes notification in JMx Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "notification in JMx" Watch "notification in JMx" New topic

notification in JMx

vinayaga moorthi

Joined: Jan 31, 2006
Posts: 14
how to write the notification and listner class for the JMX.

Henry Wong

Joined: Sep 28, 2004
Posts: 20531

Originally posted by vinayaga moorthi:
how to write the notification and listner class for the JMX.


JMX notifications is not something that you can learn in a few paragraphs, I would suggest that you pick up a good book on JMX... but I can try...

Your mbean needs to implement the NotificationBroadcaster interface (with JMX 1.2, you could also use the NotificationEmitter interface instead). One of the methods of this interface, is the add listener, which allows you to add a listener. Basically, this method should just add the notification listeners being registered in some container in the mbean.

When your mbean needs to send a notification, it should create a notification object, iterate through the container of listeners, and call the listeners handle notification method. You also need to give the hand back object back, so that the listeners will have some idea of context.

For the mbean, that is all you need to do... well, except maybe decide which notification you want to send, and how to configure it.

On the client side, you need to develop a notification listener, which is basically a class with a single handle listener method. Either get a context to the mbean server directly, or via an mbean server connector, and call the add notification listener method, to register the listener to a particular mbean.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: notification in JMx
It's not a secret anymore!