1 7 8 package javax.management; 9 10 11 import java.util.Enumeration ; 13 import java.util.Vector ; 14 15 16 26 public class AttributeChangeNotificationFilter implements NotificationFilter , java.io.Serializable { 27 28 29 private static final long serialVersionUID = -6347317584796410029L; 30 31 35 private Vector enabledAttributes = new Vector (); 36 37 38 48 public synchronized boolean isNotificationEnabled(Notification notification) { 49 50 String type = notification.getType(); 51 52 if ((type == null) || 53 (type.equals(AttributeChangeNotification.ATTRIBUTE_CHANGE) == false) || 54 (!(notification instanceof AttributeChangeNotification ))) { 55 return false; 56 } 57 58 String attributeName = 59 ((AttributeChangeNotification )notification).getAttributeName(); 60 return enabledAttributes.contains(attributeName); 61 } 62 63 72 public synchronized void enableAttribute(String name) throws java.lang.IllegalArgumentException { 73 74 if (name == null) { 75 throw new java.lang.IllegalArgumentException ("The name cannot be null."); 76 } 77 if (!enabledAttributes.contains(name)) { 78 enabledAttributes.addElement(name); 79 } 80 } 81 82 90 public synchronized void disableAttribute(String name) { 91 enabledAttributes.removeElement(name); 92 } 93 94 97 public synchronized void disableAllAttributes() { 98 enabledAttributes.removeAllElements(); 99 } 100 101 106 public synchronized Vector getEnabledAttributes() { 107 return enabledAttributes; 108 } 109 110 } 111 | Popular Tags |