|
Generating JMX Notifications
Listing 2. This implementation of the WebAppServerMXBean class includes an addWebModule() method that is called any time a new WebModule is added to the application server. public class WebAppServerMXBeanImpl
extends NEStandardMBean
implements WebAppServerMXBean {
// Implementation details removed -- see
// full source code
private ArrayList<String> webModules =
new ArrayList<String>();
private String adminEMail;
public void setAdminEMail(String adminEMail){
String oldEMail = this.adminEMail;
this.adminEMail = adminEMail;
// create and send a notification.
Notification notif = new Notification(
"jmxbp.attribute_changed", "hello", 1,
System.currentTimeMillis(),
"attribute: AdminEMail, old value: " +
oldEMail + ", new value: " + adminEMail);
sendNotification(notif);
}
// non-MBean methods.
public void addWebModule(String objectName){
webModules.add(objectName);
// create and send a notification.
Notification notif = new Notification(
"jmxbp.child_added", "hello", 1,
System.currentTimeMillis(), "test message");
sendNotification(notif);
}
}
|