3 Replies Latest reply on Sep 14, 2004 11:58 AM by dsengupt

    Registering as a listener to server startup

    dsengupt

      I am trying to find a way to register my MBean class as a listener to the server notifications, specifically so that the MBean can be notified that the startup of the Jboss server is complete. I will appreciate if someone can point me in the right direction. Thanks.

        • 1. Re: Registering as a listener to server startup
          dsengupt

          This is what i've done so far, but it gives an exception - RuntimeOperationsException: MBean jboss.system:type=Server does not implement the NotificationBroadcaster interface.
          Cause: java.lang.ClassCastException

          I'm using JBoss 3.0.4

          CODE:
          MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).iterator().next();
          Set servers = server.queryNames(new ObjectName("jboss.system:type=Server"), null);
          Iterator it = servers.iterator();
          while (it.hasNext())
          {
          ObjectName serverObjectName = (ObjectName)it.next();
          MBeanInfo info = server.getMBeanInfo(serverObjectName);
          System.out.println(info);

          NotificationFilterSupport filter = new NotificationFilterSupport();
          filter.enableType(Server.START_NOTIFICATION_TYPE);
          server.addNotificationListener(serverObjectName, this, filter, null);
          }

          • 2. Re: Registering as a listener to server startup
            dimitris

            Hi,

            the emition of the notification you want was added at v3.2+, so you won't find it in any of the 3.0.x versions.

            If you considering a more generic JMX notification listener you can try out also:

            http://www.jboss.org/wiki/Wiki.jsp?page=ExampleMinimalNotificationListener

            If you want you MBean to deploy last, you may also play with the DeploymentPrefixSorther defined at ./conf/jboss-service.xml

            Regards
            /Dimitris

            • 3. Re: Registering as a listener to server startup
              dsengupt

              Dimitris,
              Thanks for the information. I will check the links and see what i can extract out of them. Regards,
              -Deb