[jboss-cvs] JBossAS SVN: r58545 - trunk/system-jmx/src/main/org/jboss/system

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Nov 18 06:13:59 EST 2006


Author: bstansberry at jboss.com
Date: 2006-11-18 06:13:59 -0500 (Sat, 18 Nov 2006)
New Revision: 58545

Modified:
   trunk/system-jmx/src/main/org/jboss/system/BarrierController.java
Log:
If deployed via -beans.xml, don't register barrier until jmx server is avail

Modified: trunk/system-jmx/src/main/org/jboss/system/BarrierController.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/BarrierController.java	2006-11-18 11:13:11 UTC (rev 58544)
+++ trunk/system-jmx/src/main/org/jboss/system/BarrierController.java	2006-11-18 11:13:59 UTC (rev 58545)
@@ -260,19 +260,34 @@
       // create the Barrier
       barrier = new Barrier(getServiceName());
       
-      // register with the MBeanServer
-      getServer().registerMBean(barrier, barrierName);
-      
-      // implicitly call the ServiceController
-      barrier.create();
-      
-      // conditionally start the barrier
-      if (getBarrierEnabledOnStartup().booleanValue())
-      {
-         startBarrier();
+      initBarrier();
+   }
+   
+   /**
+    * Coordinates between createService() and postRegister(),
+    * registering the barrier when both the barrier is
+    * created and the mbeanserver is available
+    * 
+    * @throws Exception
+    */
+   private void initBarrier() throws Exception
+   {
+      if (barrier != null && getServer() != null)
+      {         
+         // register with the MBeanServer
+         getServer().registerMBean(barrier, barrierName);
+         
+         // implicitly call the ServiceController
+         barrier.create();
+         
+         // conditionally start the barrier
+         if (getBarrierEnabledOnStartup().booleanValue())
+         {
+            startBarrier();
+         }
+         // subscribe for notifications
+         subscribe(getDynamicSubscriptions().booleanValue());         
       }
-      // subscribe for notifications
-      subscribe(getDynamicSubscriptions().booleanValue());
    }
    
    protected void destroyService()
@@ -357,6 +372,26 @@
       }
    }
    
+   // Overrides ---------------------------------------------------
+   
+   @Override
+   public void postRegister(Boolean registrationDone)
+   {
+      super.postRegister(registrationDone);
+      
+      if (Boolean.TRUE.equals(registrationDone))
+      {
+         try
+         {
+            initBarrier();
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+   }
+   
    // Inner Class ---------------------------------------------------
    
    /**




More information about the jboss-cvs-commits mailing list