Version 6

    All jboss deployers emit JMX notifications for the deployment events defined by the SubDeployer interface contract. The following constants from the org.jboss.deployment.SubDeployer define the event types:

     

       /** The notification type send when a SubDeployer completes init */
       public static final String INIT_NOTIFICATION = "org.jboss.deployment.SubDeployer.init";
       /** The notification type send when a SubDeployer completes create */
       public static final String CREATE_NOTIFICATION = "org.jboss.deployment.SubDeployer.create";
       /** The notification type send when a SubDeployer completes start */
       public static final String START_NOTIFICATION = "org.jboss.deployment.SubDeployer.start";
       /** The notification type send when a SubDeployer completes stop */
       public static final String STOP_NOTIFICATION = "org.jboss.deployment.SubDeployer.stop";
       /** The notification type send when a SubDeployer completes destroy */
       public static final String DESTROY_NOTIFICATION = "org.jboss.deployment.SubDeployer.destroy";
    

     

    To receive these events you register as a listener of the deployer mbean service your interested in. The names of the key deployers are:

     

    • SARDeployer: "jboss.system:service=ServiceDeployer"

    • JARDeployer: "jboss.system:service=JARDeployer"

    • EARDeployer: "jboss.j2ee:service=EARDeployer"

    • EJBDeployer: "jboss.ejb:service=EJBDeployer"

    • RARDeployer: "jboss.jca:service=RARDeployer"

    • WARDeployer: "jboss.web:service=WebServer"

     

    Registering with all deployers

     

    The jboss JSR-77 layer passively creates the various management mbeans by listening for deployment events. Here is an excerpt from some of its code

    that queries the MainDeployer for all active deployers and then registers

    as listeners on the deployers.

     

       /** Register with deployers known to the MainDeployer
        *
        * @param mbeanServer
        * @throws Exception thrown on failure to register as a listener of the
        * MainDeployer or to obtain the list of deployers
        */
       private void registerWithCurrentDeployers(MBeanServer mbeanServer)
         throws Exception
       {
          ObjectName mainDeployer = new ObjectName("jboss.system:service=MainDeployer");
          log.debug("Registering with all deployers, mainDeployer="+mainDeployer);
          mbeanServer.addNotificationListener(mainDeployer, this, null, null);
    
          // Obtain the deployers list
          log.debug("Getting current deployers");
          Object[] args = {};
          String[] sig = {};
          Collection deployers = (Collection) mbeanServer.invoke(mainDeployer,
             "listDeployers", args, sig);
          Iterator iter = deployers.iterator();
          while( iter.hasNext() )
          {
             ObjectName name = (ObjectName) iter.next();
             registerWithDeployer(name);
          }
       }
       /** Register as a listener of the given deployer.
        * @param deployerName
        */
       protected void registerWithDeployer(ObjectName deployerName)
       {
          log.debug("Registering as listener of deployer: "+deployerName);
          try
          {
             getServer().addNotificationListener(deployerName, this, null, null);
          }
          catch(Exception e)
          {
             log.debug("Failed to register with deployer: "+deployerName, e);
          }
       }
    

     

     

    As as side note; the ServerImpl class emmits a Notification upon startup of the server.  The ServerImpl's ObjectName is 'jboss.system:type=Server' and the Notification type is 'org.jboss.system.server.started' (and also one for stopping - 'org.jboss.system.server.stopped').

     

     

    JBoss AS 5 and above:

     

    None of the above mentioned details applies to JBoss AS-5 and above. For more details on AS-5 deployment notifications, read this forum thread http://community.jboss.org/thread/2709