Return-Path: Delivered-To: apmail-incubator-geronimo-cvs-archive@www.apache.org Received: (qmail 90639 invoked from network); 23 Nov 2003 17:51:52 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 23 Nov 2003 17:51:52 -0000 Received: (qmail 36792 invoked by uid 500); 23 Nov 2003 17:51:43 -0000 Delivered-To: apmail-incubator-geronimo-cvs-archive@incubator.apache.org Received: (qmail 36765 invoked by uid 500); 23 Nov 2003 17:51:43 -0000 Mailing-List: contact geronimo-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-cvs@incubator.apache.org Received: (qmail 36752 invoked from network); 23 Nov 2003 17:51:43 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 23 Nov 2003 17:51:43 -0000 Received: (qmail 90611 invoked by uid 1750); 23 Nov 2003 17:51:50 -0000 Date: 23 Nov 2003 17:51:50 -0000 Message-ID: <20031123175150.90610.qmail@minotaur.apache.org> From: ammulder@apache.org To: incubator-geronimo-cvs@apache.org Subject: cvs commit: incubator-geronimo/modules/remoting/src/test/org/apache/geronimo/remoting JMXRemotingTestMain.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ammulder 2003/11/23 09:51:50 Modified: modules/remoting/src/test/org/apache/geronimo/remoting JMXRemotingTestMain.java Log: Demonstrate problem removing a NotificationListener with a Serializable filter Revision Changes Path 1.4 +31 -5 incubator-geronimo/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTestMain.java Index: JMXRemotingTestMain.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTestMain.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JMXRemotingTestMain.java 23 Nov 2003 10:56:35 -0000 1.3 +++ JMXRemotingTestMain.java 23 Nov 2003 17:51:50 -0000 1.4 @@ -57,13 +57,16 @@ package org.apache.geronimo.remoting; import java.rmi.Remote; +import java.io.Serializable; import javax.management.MBeanServer; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; +import javax.management.NotificationFilter; import org.apache.geronimo.kernel.jmx.JMXUtil; +import org.apache.geronimo.kernel.deployment.client.DeploymentNotification; import org.apache.geronimo.remoting.jmx.RemoteMBeanServerFactory; import EDU.oswego.cs.dl.util.concurrent.Latch; @@ -72,6 +75,10 @@ * this test needs for a geronimo instance to be running and * so I guess this is really a IntegrationTest and not a Unit test. * This should move into the Integration test suite once it exists. + * + * It also needs the classes in this package to be added to the + * server classpath so that the serializable NotificationListener + * can be resolved by the server. */ public class JMXRemotingTestMain { @@ -86,27 +93,46 @@ } class MyListner implements NotificationListener, Remote { + private int lookingForID = -1; /** * @see javax.management.NotificationListener#handleNotification(javax.management.Notification, java.lang.Object) */ - public void handleNotification(Notification arg0, Object arg1) { - System.out.println("Got notification: "+arg0); - System.out.println(" : "+arg1); + public void handleNotification(Notification not, Object handback) { + if(not instanceof DeploymentNotification) { + int id = ((DeploymentNotification)not).getDeploymentID(); + if(lookingForID == -1) { + lookingForID = id; + } else { + if(id != lookingForID) { + System.err.println("FAILED: should not get notification for ID "+id+" (expecting "+lookingForID+")"); + return; + } + } + } + System.out.println("Got notification: "+not.getType()); eventLatch.release(); } } + static class MyFilter implements NotificationFilter, Serializable { + public boolean isNotificationEnabled(Notification notification) { + System.err.println("Filtering a notification: "+notification.getType()); + return true; + } + } + public void testNotificationListner() throws Exception { System.out.println("adding listner.."); MBeanServer server = RemoteMBeanServerFactory.create("localhost"); ObjectName name = JMXUtil.getObjectName("geronimo.deployment:role=DeploymentController"); MyListner listner = new MyListner(); - server.addNotificationListener(name,listner,null,null); + MyFilter filter = new MyFilter(); + server.addNotificationListener(name,listner,filter,null); eventLatch.acquire(); System.out.println("Event received."); - server.removeNotificationListener(name, listner, null, null); + server.removeNotificationListener(name, listner, filter, null); System.out.println("Notifications removed."); Thread.sleep(1000*60); }