File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

notification in JMx

vinayaga moorthi
Greenhorn

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

vinayagamoorthi
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18117
    
  39

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

vinayagamoorthi


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.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
 
subject: notification in JMx
 
Similar Threads
jmx
How have bean notified if other beans deployed/undeployed?
jmx mail alerts for runtime parameters in jvm
Inheriting static methods
How to monitor dynamic values in JMX !!