1 22 package org.jboss.mx.notification; 23 24 import javax.management.NotificationFilter ; 25 import javax.management.NotificationListener ; 26 27 36 public class DefaultListenerRegistration 37 implements ListenerRegistration 38 { 39 41 44 private NotificationListener listener; 45 46 49 private NotificationFilter filter; 50 51 54 private Object handback; 55 56 58 65 public DefaultListenerRegistration(NotificationListener listener, 66 NotificationFilter filter, 67 Object handback) 68 { 69 this.listener = listener; 70 this.filter = filter; 71 this.handback = handback; 72 } 73 74 76 78 public NotificationListener getListener() 79 { 80 return listener; 81 } 82 83 public NotificationFilter getFilter() 84 { 85 return filter; 86 } 87 88 public Object getHandback() 89 { 90 return handback; 91 } 92 93 public NotificationListener getRegisteredListener() 94 { 95 return listener; 96 } 97 98 public NotificationFilter getRegisteredFilter() 99 { 100 return filter; 101 } 102 103 public void removed() 104 { 105 } 106 107 public boolean equals(Object obj) 108 { 109 if (obj == null || (obj instanceof ListenerRegistration) == false) 110 return false; 111 ListenerRegistration other = (ListenerRegistration) obj; 112 113 if (getRegisteredListener().equals(other.getRegisteredListener()) == false) 114 return false; 115 116 NotificationFilter myFilter = getRegisteredFilter(); 117 NotificationFilter otherFilter = other.getRegisteredFilter(); 118 if (myFilter != null && myFilter.equals(otherFilter) == false) 119 return false; 120 else if (myFilter == null && otherFilter != null) 121 return false; 122 123 Object myHandback = getHandback(); 124 Object otherHandback = other.getHandback(); 125 if (myHandback != null && myHandback.equals(otherHandback) == false) 126 return false; 127 else if (myHandback == null && otherHandback != null) 128 return false; 129 130 return true; 131 } 132 133 public int hashCode() 134 { 135 int result = listener.hashCode(); 136 if (filter != null) 137 result += filter.hashCode(); 138 if (handback != null) 139 result += handback.hashCode(); 140 return result; 141 } 142 143 public String toString() 144 { 145 StringBuffer buffer = new StringBuffer (50); 146 buffer.append(getClass()).append(":"); 147 buffer.append(" listener=").append(getRegisteredListener()); 148 buffer.append(" filter=") .append(getRegisteredFilter()); 149 buffer.append(" handback=").append(getHandback()); 150 return buffer.toString(); 151 } 152 } 153 | Popular Tags |