0 Replies Latest reply on Nov 8, 2002 9:03 AM by Srivatsan

    Reg. JSR-77

    Srivatsan Newbie

      Hi,
      I am interested in listening for the events that are emitted during deployment of applications or modules. I registered a listener using the ListenerRegistration and I am not getting any notifications. I am attaching my code here. Am I doing anything wrong?

      **********MBeanService*******
      public class MyTest extends ServiceMBeanSupport implements MyTestMBean
      {
      public String getName()
      {
      return "MyTest";
      }

      public void startService() throws Exception
      {
      System.out.println("inside start service....");
      Context ic = new InitialContext();

      java.lang.Object objref = ic.lookup("ejb/mgmt/MEJB");
      ManagementHome home = (ManagementHome)PortableRemoteObject.narrow(objref,ManagementHome.class);

      Management mejb = home.create();

      ObjectName objectname = new ObjectName("jboss:test=MyTest");
      javax.management.j2ee.ListenerRegistration lr = mejb.getListenerRegistry();
      lr.addNotificationListener(objectname,new TestListener() , new MyFilter() , "MEJBTester");
      System.out.println("Added Notification Listener**");
      }
      }

      ***********TestListener*********
      public class TestListener implements Serializable, NotificationListener
      {
      public void handleNotification(Notification n,Object hb)
      {
      System.out.println("Message==****==" + n.getMessage());
      System.out.println("Type==****==" + n.getType());
      }

      }

      ***********MyFilter************
      public class MyFilter implements NotificationFilter,Serializable
      {
      public boolean isNotificationEnabled(Notification notification)
      {
      System.out.println("returning true%%");
      return true;
      }
      }