[jboss-cvs] JBossAS SVN: r59405 - in projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers: plugins/deployment spi/deployment

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 8 01:09:36 EST 2007


Author: scott.stark at jboss.org
Date: 2007-01-08 01:09:29 -0500 (Mon, 08 Jan 2007)
New Revision: 59405

Modified:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
Log:
Add a process(int,int) to allow partial processing of deployments.

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2007-01-07 17:38:44 UTC (rev 59404)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2007-01-08 06:09:29 UTC (rev 59405)
@@ -73,6 +73,7 @@
  * TODO implement attachment flow see comment in {@link Deployer}
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
  * @version $Revision: 1.1 $
  */
 public class MainDeployerImpl implements MainDeployer
@@ -374,11 +375,23 @@
 
    public void process()
    {
+      process(-1, Integer.MAX_VALUE);
+   }
+   /**
+    * Process the new deployments.
+    * 
+    * TODO: Only deployment uses begin/end. Does it make sense to have
+    * partial undeployment?
+    * 
+    */
+   public Collection<DeploymentContext> process(int begin, int end)
+   {
       if (shutdown.get())
          throw new IllegalStateException("The main deployer is shutdown");
 
       List<DeploymentContext> undeployContexts = null;
       List<DeploymentContext> deployContexts = null;
+      List<DeploymentContext> processedContexts = new ArrayList<DeploymentContext>();
       Deployer[] theDeployers;
       synchronized (this)
       {
@@ -395,7 +408,6 @@
          if (deploy.isEmpty() == false)
          {
             deployContexts = new ArrayList<DeploymentContext>(deploy);
-            deploy.clear();
          }
          theDeployers = deployers.toArray(new Deployer[deployers.size()]); 
       }
@@ -420,10 +432,32 @@
       
       if (deployContexts != null)
       {
+         // Restrict deployers to begin/end range
+         boolean validDeployersIncludesLastDeployer = false;
+         ArrayList<Deployer> validDeployers = new ArrayList<Deployer>();
          for (int i = 0; i < theDeployers.length; ++i)
          {
             Deployer deployer = theDeployers[i];
+            int order = deployer.getRelativeOrder();
+            // If the deployer is in the [begin, end) range
+            if( (begin <= order && order < end) ||
+                  // Integer.MAX_VALUE has to be treated specially since its used by deployers
+                  // TODO change the default deployer order to Integer.MAX_VALUE-1
+                  (begin <= order && end == Integer.MAX_VALUE) )
+            {
+               validDeployers.add(deployer);
+               if( i == theDeployers.length-1 )
+                  validDeployersIncludesLastDeployer = true;
+            }
+         }
+         // Clear the deployments if the all deployments
+         if (validDeployersIncludesLastDeployer)
+            deploy.clear();
 
+         for (int i = 0; i < validDeployers.size(); ++i)
+         {
+            Deployer deployer = validDeployers.get(i);
+
             Set<DeploymentContext> errors = new HashSet<DeploymentContext>();
             for (DeploymentContext context : deployContexts)
             {
@@ -441,7 +475,7 @@
                   // Unwind the deployment
                   for (int j = i-1; j >= 0; --j)
                   {
-                     Deployer other = theDeployers[j];
+                     Deployer other = validDeployers.get(j);
                      prepareUndeploy(other, context, true);
                   }
                   context.removeClassLoader();
@@ -457,12 +491,15 @@
             VirtualFile root = context.getRoot();
             if (root != null && root.getName().endsWith(".jar"))
                isJar = true;
-            if (context.isDeployed() == false && isJar == false)
+            if (validDeployersIncludesLastDeployer && context.isDeployed() == false && isJar == false)
                missingDeployers.put(name, context);
+            // TODO: Should there be a PARTIAL_DEPLOYED state for end < max deployer
             context.setState(DEPLOYED);
+            processedContexts.add(context);
             log.debug("Deployed: " + name);
          }
       }
+      return processedContexts;
    }
 
    private void prepareUndeploy(Deployer deployer, DeploymentContext context, boolean doComponents)

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java	2007-01-07 17:38:44 UTC (rev 59404)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java	2007-01-08 06:09:29 UTC (rev 59405)
@@ -112,9 +112,21 @@
    boolean removeDeploymentContext(String name) throws DeploymentException;
 
    /**
-    * Process the outstanding deployments
+    * Process the outstanding deployments.
+    * This is equivalent to calling process(-1, Integer.MAX_VALUE).
     */
    void process();
+   /**
+    * Process all the outstanding deployments through the deployers whose
+    * relative order is in the range [begin, end), which begin <= ro < end.
+    * 
+    * @param begin - the minimum relative order value of of deployers to
+    * use
+    * @param end - the max relative order value of of deployers to
+    * use
+    * @return the top-level DeploymentContexts that were processed 
+    */
+   Collection<DeploymentContext> process(int begin, int end);
    
    /**
     * Shutdown. Removes all the deployments.




More information about the jboss-cvs-commits mailing list