[jboss-cvs] JBossAS SVN: r84500 - projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/main.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 20 04:48:49 EST 2009


Author: alesj
Date: 2009-02-20 04:48:49 -0500 (Fri, 20 Feb 2009)
New Revision: 84500

Modified:
   projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java
Log:
Write lock just deploy/undeploy lists processing.

Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java	2009-02-20 09:06:42 UTC (rev 84499)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java	2009-02-20 09:48:49 UTC (rev 84500)
@@ -322,33 +322,41 @@
     */
    protected void processToDeploy() throws DeploymentException
    {
-      List<String> added = new ArrayList<String>();
+      lockRead();
       try
       {
-         for (Map.Entry<String, Deployment> entry : toDeploy.entrySet())
+         List<String> added = new ArrayList<String>();
+         try
          {
-            determineDeploymentContext(entry.getValue(), true);
-            added.add(entry.getKey());
+            for (Map.Entry<String, Deployment> entry : toDeploy.entrySet())
+            {
+               determineDeploymentContext(entry.getValue(), true);
+               added.add(entry.getKey());
+            }
          }
-      }
-      catch (DeploymentException e)
-      {
-         ListIterator<String> iter = added.listIterator(added.size());
-         while (iter.hasPrevious())
+         catch (DeploymentException e)
          {
-            try
+            ListIterator<String> iter = added.listIterator(added.size());
+            while (iter.hasPrevious())
             {
-               removeDeployment(iter.previous(), true);
+               try
+               {
+                  removeDeployment(iter.previous(), true);
+               }
+               catch (Throwable  ignored)
+               {
+               }
             }
-            catch (Throwable  ignored)
-            {
-            }
+            throw e;
          }
-         throw e;
+         finally
+         {
+            toDeploy.clear();
+         }
       }
       finally
       {
-         toDeploy.clear();
+         unlockRead();
       }
    }
 
@@ -623,13 +631,13 @@
       if (deployers == null)
          throw new IllegalStateException("No deployers");
 
+      List<DeploymentContext> undeployContexts = null;
       lockWrite();
       try
       {
          if (shutdown.get())
             throw new IllegalStateException("The main deployer is shutdown");
 
-         List<DeploymentContext> undeployContexts = null;
          if (undeploy.isEmpty() == false)
          {
             // Undeploy in reverse order (subdeployments first)
@@ -640,21 +648,33 @@
                Collections.sort(undeployContexts, reverted);
             undeploy.clear();
          }
-         if (undeployContexts != null)
-         {
-            deployers.process(null, undeployContexts);
-         }
+      }
+      finally
+      {
+         unlockWrite();
+      }
 
-         try
-         {
-            processToDeploy();
-         }
-         catch (DeploymentException e)
-         {
-            throw new RuntimeException("Error while processing new deployments", e);
-         }
+      if (undeployContexts != null)
+      {
+         deployers.process(null, undeployContexts);
+      }
 
-         List<DeploymentContext> deployContexts = null;
+      try
+      {
+         processToDeploy();
+      }
+      catch (DeploymentException e)
+      {
+         throw new RuntimeException("Error while processing new deployments", e);
+      }
+
+      List<DeploymentContext> deployContexts = null;
+      lockWrite();
+      try
+      {
+         if (shutdown.get())
+            throw new IllegalStateException("The main deployer is shutdown");
+
          if (deploy.isEmpty() == false)
          {
             deployContexts = new ArrayList<DeploymentContext>(deploy);
@@ -662,15 +682,16 @@
                Collections.sort(deployContexts, comparator);
             deploy.clear();
          }
-         if (deployContexts != null)
-         {
-            deployers.process(deployContexts, null);
-         }
       }
       finally
       {
          unlockWrite();
       }
+
+      if (deployContexts != null)
+      {
+         deployers.process(deployContexts, null);
+      }
    }
 
    public DeploymentStage getDeploymentStage(String deploymentName) throws DeploymentException




More information about the jboss-cvs-commits mailing list