2 Replies Latest reply on Jun 19, 2008 3:46 AM by Frank

    How can I receive notification when Servlet stats change ?

    Frank Newbie

      Hi all !
      I'd need to add a notification listener that warns me when Servlet stats change. Until now I have been using successfully this code for my MBeans notifications

      NotificationListener notificationListener = new NotificationListener() {
       public void handleNotification(Notification notification, Object handback) {
       System.out.println("Notification received!");
       System.out.println("UserObject: " + notification.getUserData());
       }
      };
      try {
      
       ArrayList servers = MBeanServerFactory.findMBeanServer(null);
       if (servers == null)
       throw new Exception("No MBeanServer found.");
       MBeanServer server = (MBeanServer)servers.get(0);
      
       // find the local MBeanServer
       ObjectName objectName = new ObjectName("jboss.management.local:J2EEApplication=null,J2EEServer=Local,WebModule=stats.war,j2eeType=Servlet,name=ControllerServlet");
       server.addNotificationListener(objectName, notificationListener, null, null);
      
       Thread.sleep(20000);
      } catch (MalformedObjectNameException ex) {
       // manage
      } catch (InstanceNotFoundException ex) {
       // manage
      }


      Anyway once I have registered to my Servlet nothing happens, even if the stats change (because I invoke my Servlet).
      How can I get notification when my Servlet "ControllerServlet" is invoked ?

      Thanks a lot
      Francesco