[jboss-cvs] JBossAS SVN: r59201 - branches/Branch_4_2/system/src/main/org/jboss/system

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 21 14:03:49 EST 2006


Author: dimitris at jboss.org
Date: 2006-12-21 14:03:46 -0500 (Thu, 21 Dec 2006)
New Revision: 59201

Modified:
   branches/Branch_4_2/system/src/main/org/jboss/system/BarrierController.java
   branches/Branch_4_2/system/src/main/org/jboss/system/BarrierControllerMBean.java
Log:
JBAS-3469, Enhance the BarrierController with the ability to destroy/re-create the Barrier

Modified: branches/Branch_4_2/system/src/main/org/jboss/system/BarrierController.java
===================================================================
--- branches/Branch_4_2/system/src/main/org/jboss/system/BarrierController.java	2006-12-21 18:22:23 UTC (rev 59200)
+++ branches/Branch_4_2/system/src/main/org/jboss/system/BarrierController.java	2006-12-21 19:03:46 UTC (rev 59201)
@@ -61,14 +61,23 @@
    private ObjectName barrierName;
 
    /** The initial state of the barrier */
+   private Boolean createOnStartup;
+   
+   /** The initial state of the barrier */
    private Boolean enableOnStartup;
    
+   /** The notification subscription handback string that creates the barrier */ 
+   private String createHandback;
+   
    /** The notification subscription handback string that starts the barrier */ 
    private String startHandback;
    
    /** The notification subscription handback string that stops the barrier */
    private String stopHandback;
    
+   /** The notification subscription handback string that destroys the barrier */ 
+   private String destroyHandback;
+   
    /** The dynamic subscriptions flag */
    private Boolean dynamicSubscriptions;
    
@@ -123,8 +132,35 @@
       return barrierName;
    }
 
-
    /**
+    * Whether the Barrier should be created on startup
+    * 
+    * @jmx.managed-attribute
+    */
+   public void setBarrierCreatedOnStartup(Boolean createOnStartup)
+   {
+      // set once
+      if (this.createOnStartup == null)
+      {
+         this.createOnStartup = createOnStartup;
+      }
+   }
+   
+   /**
+    * Whether the Barrier should be created on startup
+    * 
+    * @jmx.managed-attribute
+    */   
+   public Boolean getBarrierCreatedOnStartup()
+   {
+      if (createOnStartup == null)
+      {
+         createOnStartup = Boolean.TRUE;
+      }
+      return createOnStartup;
+   }
+   
+   /**
     * The initial state of the barrier.
     * 
     * If set, it overrides the internal call to enableOnStartup()
@@ -140,7 +176,7 @@
          this.enableOnStartup = enableOnStartup;
       }
    }
-
+   
    /**
     * The initial state of the barrier.
     * 
@@ -162,6 +198,30 @@
    }
    
    /**
+    * The notification subscription handback string that creates the barrier.
+    * 
+    * @jmx.managed-attribute
+    */   
+   public void setCreateBarrierHandback(String createHandback)
+   {
+      // set once
+      if (this.createHandback == null)
+      {
+         this.createHandback = createHandback;
+      }
+   }
+
+   /**
+    * The notification subscription handback string that creates the barrier.
+    * 
+    * @jmx.managed-attribute
+    */   
+   public String getCreateBarrierHandback()
+   {
+      return createHandback;
+   }
+   
+   /**
     * The notification subscription handback string that starts the barrier.
     * 
     * @jmx.managed-attribute
@@ -210,6 +270,30 @@
    }
    
    /**
+    * The notification subscription handback string that destroys the barrier.
+    * 
+    * @jmx.managed-attribute
+    */   
+   public void setDestroyBarrierHandback(String destroyHandback)
+   {
+      // set once
+      if (this.destroyHandback == null)
+      {
+         this.destroyHandback = destroyHandback;
+      }
+   }
+   
+   /**
+    * The notification subscription handback string that destroys the barrier.
+    * 
+    * @jmx.managed-attribute
+    */   
+   public String getDestroyBarrierHandback()
+   {
+      return destroyHandback;
+   }
+   
+   /**
     * The ability to dynamically subscribe for notifications.
     *
     * @jmx.managed-attribute
@@ -263,14 +347,19 @@
       // register with the MBeanServer
       getServer().registerMBean(barrier, barrierName);
       
-      // implicitly call the ServiceController
-      barrier.create();
+      // conditionally put the Barrier in create state
+      if (getBarrierCreatedOnStartup().booleanValue())
+      {
+         // implicitly call the ServiceController
+         barrier.create();
+      }
       
-      // conditionally start the barrier
+      // conditionally put the Barrier in start state
       if (getBarrierEnabledOnStartup().booleanValue())
       {
          startBarrier();
       }
+      
       // subscribe for notifications
       subscribe(getDynamicSubscriptions().booleanValue());
    }
@@ -280,17 +369,17 @@
       // unsubscribe for notifications
       unsubscribe();
 
+      // put the Barrier in destroy state
+      destroyBarrier();
+      
       try
       {
-         // implicitly call the ServiceController
-         barrier.destroy();
-      
          // remove from MBeanServer
          getServer().unregisterMBean(barrierName);
       }
       catch (Throwable e)
       {
-         log.debug("Unexpected error during destroy", e);
+         log.debug("Unexpected error during Barrier unregister", e);
       }
       
       // cleanup
@@ -307,8 +396,13 @@
    {
       log.debug("Got notification: " + n);
       
-      if (startHandback != null && startHandback.equals(handback))
+      if (createHandback != null && createHandback.equals(handback))
       {
+         log.debug("Saw '" + handback + "' handback, creating barrier");
+         createBarrier();
+      }      
+      else if (startHandback != null && startHandback.equals(handback))
+      {
          log.debug("Saw '" + handback + "' handback, starting barrier");
          startBarrier();
       }
@@ -317,11 +411,34 @@
          log.debug("Saw '" + handback + "' handback, stopping barrier");
          stopBarrier();
       }
+      else if (destroyHandback != null && destroyHandback.equals(handback))
+      {
+         log.debug("Saw '" + handback + "' handback, destroying barrier");
+         destroyBarrier();
+      }
    }
    
    // Operations ----------------------------------------------------
 
    /**
+    * Manually create the controlled barrier
+    * 
+    * @jmx:managed-operation
+    */
+   public void createBarrier()
+   {
+      try
+      {
+         // implicitly call the ServiceController
+         barrier.create();
+      }
+      catch (Throwable e)
+      {
+         log.warn("Failed to create barrier: " + barrierName, e);
+      }
+   }
+   
+   /**
     * Manually start the controlled barrier
     * 
     * @jmx:managed-operation
@@ -357,6 +474,24 @@
       }
    }
    
+   /**
+    * Manually destroy the controlled barrier
+    * 
+    * @jmx:managed-operation
+    */
+   public void destroyBarrier()
+   {
+      try
+      {
+         // implicitly call the ServiceController
+         barrier.destroy();
+      }
+      catch (Throwable e)
+      {
+         log.warn("Failed to destroy barrier: " + barrierName, e);
+      }
+   }
+   
    // Inner Class ---------------------------------------------------
    
    /**

Modified: branches/Branch_4_2/system/src/main/org/jboss/system/BarrierControllerMBean.java
===================================================================
--- branches/Branch_4_2/system/src/main/org/jboss/system/BarrierControllerMBean.java	2006-12-21 18:22:23 UTC (rev 59200)
+++ branches/Branch_4_2/system/src/main/org/jboss/system/BarrierControllerMBean.java	2006-12-21 19:03:46 UTC (rev 59201)
@@ -47,11 +47,18 @@
    void setBarrierObjectName(ObjectName barrierName);   
    ObjectName getBarrierObjectName();
    
-   /** The initial state of the barrier. If set, it overrides the internal call
-    * to enableOnStartup() which will never get called. */
-   void setBarrierEnabledOnStartup(Boolean enableOnStartup);
+   /** Whether the Barrier should be created on startup */
+   void setBarrierCreatedOnStartup(Boolean createdOnStartup);
+   Boolean getBarrierCreatedOnStartup();
+   
+   /** Whether the Barrier should be started on startup. */
+   void setBarrierEnabledOnStartup(Boolean startedOnStartup);
    Boolean getBarrierEnabledOnStartup();
    
+   /** The notification subscription handback string that creates the barrier. */
+   void setCreateBarrierHandback(String createHandback);
+   String getCreateBarrierHandback();
+   
    /** The notification subscription handback string that starts the barrier. */
    void setStartBarrierHandback(String startHandback);
    String getStartBarrierHandback();
@@ -59,6 +66,10 @@
    /** The notification subscription handback string that stops the barrier. */
    void setStopBarrierHandback(String stopHandback);
    String getStopBarrierHandback();
+   
+   /** The notification subscription handback string that destroys the barrier. */
+   void setDestroyBarrierHandback(String destroyHandback);
+   String getDestroyBarrierHandback();   
 
    /** The ability to dynamically subscribe for notifications. */
    void setDynamicSubscriptions(Boolean dynamicSubscriptions);
@@ -67,6 +78,11 @@
    // Operations ----------------------------------------------------
    
    /**
+    * Manually create the controlled barrier
+    */
+   void createBarrier();
+   
+   /**
     * Manually start the controlled barrier
     */
    void startBarrier();
@@ -76,4 +92,9 @@
     */
    void stopBarrier();
 
+   /**
+    * Manually destroy the controlled barrier
+    */
+   void destroyBarrier();
+   
 }




More information about the jboss-cvs-commits mailing list