1 22 package org.jboss.test.jmx.xmbean; 23 24 import javax.management.AttributeChangeNotification ; 25 import javax.management.Notification ; 26 import javax.management.NotificationListener ; 27 28 import org.jboss.system.ServiceMBeanSupport; 29 30 42 public class SelfListenerService 43 extends ServiceMBeanSupport 44 implements NotificationListener 45 { 46 private boolean attr1 = false; 47 private boolean gotAttr1AVC = false; 48 49 public boolean getAttr1() 50 { 51 return attr1; 52 } 53 54 public void setAttr1(boolean attr1) 55 { 56 this.attr1 = attr1; 57 } 58 59 public boolean getGotAttr1AVC() 60 { 61 return gotAttr1AVC; 62 } 63 64 protected void startService() 65 throws Exception 66 { 67 server.addNotificationListener(super.serviceName, this, null, null); 68 } 69 70 protected void stopService() 71 throws Exception 72 { 73 server.removeNotificationListener(super.serviceName, this); 74 } 75 76 public void handleNotification(Notification notif, Object handback) 77 { 78 log.info("handleNotification: " + notif); 79 80 if (notif instanceof AttributeChangeNotification ) 81 { 82 AttributeChangeNotification avc = (AttributeChangeNotification )notif; 83 84 if (avc.getAttributeName().equals("Attr1")) 85 { 86 Boolean newValue = (Boolean )avc.getNewValue(); 87 88 if (Boolean.TRUE.equals(newValue)) 89 this.gotAttr1AVC = true; 90 } 91 } 92 } 93 } 94 | Popular Tags |