[Jboss-cvs] JBossAS SVN: r55153 - branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/plugins

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 3 21:29:32 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-08-03 21:29:31 -0400 (Thu, 03 Aug 2006)
New Revision: 55153

Modified:
   branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/plugins/AbstractAspectDeployer.java
Log:
Add a generateDeployerEvent(DeploymentContext ctx, DeploymentEvent type) for generate kernel events for deployment ops

Modified: branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/plugins/AbstractAspectDeployer.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/plugins/AbstractAspectDeployer.java	2006-08-04 01:26:35 UTC (rev 55152)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/plugins/AbstractAspectDeployer.java	2006-08-04 01:29:31 UTC (rev 55153)
@@ -21,16 +21,21 @@
  */
 package org.jboss.deployers.plugins;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.jboss.deployers.spi.AspectDeployer;
 import org.jboss.deployers.spi.DeploymentContext;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.MainDeployer;
+import org.jboss.kernel.plugins.event.AbstractEvent;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.jboss.kernel.spi.event.KernelEventManager;
 import org.jboss.util.JBossObject;
 /**
  * Abstract base for AspectDeployers. This is KernelControllerContextAware to
- * allow deployers to have access to the kernel and state info.
+ * allow deployers to have access to the server kernel and state info.
  * 
  * TODO: the suffix ordering notion seems obsolete with the deployer chain
  * 
@@ -64,7 +69,8 @@
    protected int relativeOrder = DeployerConstants.DEFAULT_DEPLOYER_ORDER;
    /** The MC kernel context */
    protected KernelControllerContext context;
-   
+   protected AtomicLong eventSequence = new AtomicLong();
+
    // Constructors --------------------------------------------------
    
    /**
@@ -178,12 +184,31 @@
    {
       return relativeOrder;
    }
-   
+
+   /**
+    * A stub method that should be overriden by deployers that want to
+    * associate themselves with a deployment context.
+    * 
+    * @param ctx - the current deployment context being processed
+    * @return false always
+    * @throws DeploymentException - thrown on a fatal error that should
+    *    prevent deployment
+    */
    public boolean analyze(DeploymentContext ctx) throws DeploymentException
    {
       return false;
    }
 
+   /**
+    * This is just an undeploy/deploy cycle. Subclasses should override if
+    * they have a more intelligent redeploy.
+    */
+   public void redeploy(DeploymentContext ctx) throws DeploymentException
+   {
+      undeploy(ctx);
+      deploy(ctx);
+   }
+
    // KernelControllerContextAware implements -----------------------------
    public void setKernelControllerContext(KernelControllerContext context)
       throws Exception
@@ -198,27 +223,60 @@
       this.context = null;
    }
 
+   /**
+    * Accessor for the kernel the deployer is associated with
+    * @return the current kernel context if one exists
+    */
    public KernelControllerContext getKernelContext()
    {
       return context;
    }
 
    // Lifecycle overrides -------------------------------------------
-   
+   /**
+    * A noop kernel create lifecycle callback.
+    */
    public void create() throws Exception {}
-   
+
+   /**
+    * The kernel start lifecycle callback. This registers the deployer with
+    * the mainDeployer and should be called by subclasses after they are
+    * started.
+    */
    public void start() throws Exception
    {
       mainDeployer.register(this);
    }
    
+   /**
+    * The kernel stop lifecycle callback. This unregisters the deployer with
+    * the mainDeployer and should be called by subclasses before they are
+    * stopped.
+    */
    public void stop()
    {
       mainDeployer.unregister(this);
    }
    
+   /**
+    * A noop kernel destroy lifecycle callback.
+    */
    public void destroy() {}
    
+   // Object overrides ----------------------------------------------
+   /**
+    * Deployer equality is based on the deployerName
+    */
+   public boolean equals(Object other)
+   {
+      if (other instanceof AbstractAspectDeployer)
+      {
+         AbstractAspectDeployer deployer = (AbstractAspectDeployer) other;
+         return deployer.deployerName.equals(this.deployerName);
+      }
+      return false;
+   }
+
    // JBossObject overrides -----------------------------------------
    
    public void toShortString(StringBuffer buffer)
@@ -235,18 +293,7 @@
    {
       return deployerName.hashCode();
    }
-   
-   // Object overrides ----------------------------------------------
-   
-   public boolean equals(Object other)
-   {
-      if (other instanceof AbstractAspectDeployer)
-      {
-         return ((AbstractAspectDeployer)other).deployerName.equals(this.deployerName);
-      }
-      return false;
-   }
-   
+
    // Protected -----------------------------------------------------
    
    /**
@@ -263,4 +310,19 @@
       }
       return false;
    }
+
+   /**
+    * Generate a KernelEvent(this, type, eventSequence, System.currentTimeMillis(), ctx)
+    * @param ctx - the deployment context associated with the event
+    * @param type - the type of deployment event
+    */
+   protected void generateDeployerEvent(DeploymentContext ctx, DeploymentEvent type)
+   {
+      KernelEventManager eventMgr = getKernelContext().getKernel().getEventManager();
+      String typeName = type.toString();
+      long sequence = eventSequence.incrementAndGet();
+      long ts = System.currentTimeMillis();
+      KernelEvent event = new AbstractEvent(this, typeName, sequence, ts, ctx);
+      eventMgr.fireKernelEvent(event);
+   }
 }




More information about the jboss-cvs-commits mailing list