geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject cvs commit: incubator-geronimo/modules/remoting/src/test/org/apache/geronimo/remoting JMXRemotingTestMain.java
Date Sun, 23 Nov 2003 17:51:50 GMT
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);
       }
  
  
  

Mime
View raw message