1 7 8 package javax.management; 9 10 46 public class StandardEmitterMBean extends StandardMBean 47 implements NotificationEmitter { 48 49 private final NotificationEmitter emitter; 50 private final MBeanNotificationInfo [] notificationInfo; 51 52 82 public <T> StandardEmitterMBean(T implementation, Class <T> mbeanInterface, 83 NotificationEmitter emitter) { 84 super(implementation, mbeanInterface, false); 85 if (emitter == null) 86 throw new IllegalArgumentException ("Null emitter"); 87 this.emitter = emitter; 88 this.notificationInfo = emitter.getNotificationInfo(); 89 } 90 91 126 public <T> StandardEmitterMBean(T implementation, Class <T> mbeanInterface, 127 boolean isMXBean, 128 NotificationEmitter emitter) { 129 super(implementation, mbeanInterface, isMXBean); 130 if (emitter == null) 131 throw new IllegalArgumentException ("Null emitter"); 132 this.emitter = emitter; 133 this.notificationInfo = emitter.getNotificationInfo(); 134 } 135 136 167 protected StandardEmitterMBean(Class <?> mbeanInterface, 168 NotificationEmitter emitter) { 169 super(mbeanInterface, false); 170 if (emitter == null) 171 throw new IllegalArgumentException ("Null emitter"); 172 this.emitter = emitter; 173 this.notificationInfo = emitter.getNotificationInfo(); 174 } 175 176 210 protected StandardEmitterMBean(Class <?> mbeanInterface, boolean isMXBean, 211 NotificationEmitter emitter) { 212 super(mbeanInterface, isMXBean); 213 if (emitter == null) 214 throw new IllegalArgumentException ("Null emitter"); 215 this.emitter = emitter; 216 this.notificationInfo = emitter.getNotificationInfo(); 217 } 218 219 public void removeNotificationListener(NotificationListener listener) 220 throws ListenerNotFoundException { 221 emitter.removeNotificationListener(listener); 222 } 223 224 public void removeNotificationListener(NotificationListener listener, 225 NotificationFilter filter, 226 Object handback) 227 throws ListenerNotFoundException { 228 emitter.removeNotificationListener(listener, filter, handback); 229 } 230 231 public void addNotificationListener(NotificationListener listener, 232 NotificationFilter filter, 233 Object handback) { 234 emitter.addNotificationListener(listener, filter, handback); 235 } 236 237 public MBeanNotificationInfo [] getNotificationInfo() { 238 return notificationInfo; 239 } 240 241 255 public void sendNotification(Notification n) { 256 if (emitter instanceof NotificationBroadcasterSupport ) 257 ((NotificationBroadcasterSupport ) emitter).sendNotification(n); 258 else { 259 final String msg = 260 "Cannot sendNotification when emitter is not an " + 261 "instance of NotificationBroadcasterSupport: " + 262 emitter.getClass().getName(); 263 throw new ClassCastException (msg); 264 } 265 } 266 267 277 MBeanNotificationInfo [] getNotifications(MBeanInfo info) { 278 return getNotificationInfo(); 279 } 280 } 281 | Popular Tags |