public static Object newInstance(ObjectName name, NotificationListener listener) { // Using set so don't have interface duplicates (which shouldn't happen anyways) java.util.HashSet set = new java.util.HashSet(); // Walk the class heirarchy tree and get all interfaces. Class currentClass = listener.getClass(); while(currentClass != null) { Class[] classInterfaces = currentClass.getInterfaces(); for(int i = 0; i < classInterfaces.length; i++) { set.add(classInterfaces[i]); } currentClass = currentClass.getSuperclass(); } Class[] interfaces = new Class[set.size()]; interfaces = (Class[])set.toArray(interfaces); return Proxy.newProxyInstance(listener.getClass().getClassLoader(), interfaces, new NotificationListenerProxy(name, listener)); }
return proxyHashCode(proxy); return proxyEquals(proxy, args[0]); return proxyToString(proxy);
/** * Create a listener registration * * @param name the object name to use as the notifiation source * @param broadcaster the notification broadcaster * @param listener the notification listener * @param filter the notification filter * @param handback the handback object a */ public MBeanServerListenerRegistration(ObjectName name, NotificationBroadcaster broadcaster, NotificationListener listener, NotificationFilter filter, Object handback) { super(listener, filter, handback); proxy = (NotificationListener) NotificationListenerProxy.newInstance(name, listener); this.broadcaster = broadcaster; this.filterProxy = (filter==null) ? null : new NotificationFilterProxy(name,filter); broadcaster.addNotificationListener(proxy, filterProxy, handback); }
/** * Create a listener registration * * @param name the object name to use as the notifiation source * @param broadcaster the notification broadcaster * @param listener the notification listener * @param filter the notification filter * @param handback the handback object a */ public MBeanServerListenerRegistration(ObjectName name, NotificationBroadcaster broadcaster, NotificationListener listener, NotificationFilter filter, Object handback) { super(listener, filter, handback); proxy = (NotificationListener) NotificationListenerProxy.newInstance(name, listener); this.broadcaster = broadcaster; this.filterProxy = (filter==null) ? null : new NotificationFilterProxy(name,filter); broadcaster.addNotificationListener(proxy, filterProxy, handback); }
return proxyHashCode(proxy); return proxyEquals(proxy, args[0]); return proxyToString(proxy);
public static Object newInstance(ObjectName name, NotificationListener listener) { // Using set so don't have interface duplicates (which shouldn't happen anyways) java.util.HashSet set = new java.util.HashSet(); // Walk the class heirarchy tree and get all interfaces. Class currentClass = listener.getClass(); while(currentClass != null) { Class[] classInterfaces = currentClass.getInterfaces(); for(int i = 0; i < classInterfaces.length; i++) { set.add(classInterfaces[i]); } currentClass = currentClass.getSuperclass(); } Class[] interfaces = new Class[set.size()]; interfaces = (Class[])set.toArray(interfaces); return Proxy.newProxyInstance(listener.getClass().getClassLoader(), interfaces, new NotificationListenerProxy(name, listener)); }