[jboss-cvs] JBossAS SVN: r100761 - projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/plugins.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 9 11:22:41 EST 2010


Author: kabir.khan at jboss.com
Date: 2010-02-09 11:22:40 -0500 (Tue, 09 Feb 2010)
New Revision: 100761

Modified:
   projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/plugins/AbstractController.java
Log:
Only check the ContextsInstalledByExecutor's map once during resolveContexts

Modified: projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/plugins/AbstractController.java
===================================================================
--- projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/plugins/AbstractController.java	2010-02-09 16:04:39 UTC (rev 100760)
+++ projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/plugins/AbstractController.java	2010-02-09 16:22:40 UTC (rev 100761)
@@ -1306,12 +1306,14 @@
          for (ControllerContext ctx : contexts)
          {
             Object name = ctx.getName();
+            AsynchronousInstallStatus asynchStatus = contextsInstalledByExecutor.checkInstalled(ctx);
+            
             if (fromState.equals(ctx.getState()) == false)
             {
                if (trace)
                   log.trace("Skipping already installed " + name + " for " + toState.getStateString());
             }
-            else if (contextsInstalledByExecutor.isInstalledByOtherThread(ctx))
+            else if (asynchStatus == AsynchronousInstallStatus.OTHER_THREAD)
             {
                if (trace)
                   log.trace("Installed by other thread " + name);
@@ -1321,7 +1323,7 @@
                if (trace)
                   log.trace("Already installing " + name + " for " + toState.getStateString());
             }
-            else if (contextsInstalledByExecutor.isBeingInstalled(ctx) == true)
+            else if (asynchStatus == AsynchronousInstallStatus.IN_PROGRESS)
             {
                if (trace)
                   log.trace("Already installing " + name + " for " + toState.getStateString());
@@ -2293,7 +2295,7 @@
       if (context.getMode() != ControllerMode.ASYNCHRONOUS)
          return false;
 
-      return contextsInstalledByExecutor.isBeingInstalled(context);
+      return contextsInstalledByExecutor.checkInstalled(context) != AsynchronousInstallStatus.NOT_INSTALLING;
    }
 
    /**
@@ -2540,25 +2542,19 @@
       }
       
       /**
-       * Checks if the context is recorded for asynchronous install, and if the thread used is different
-       * from the current thread. 
-       * @param context The context to check
-       * @return true if installed by another thread
-       */
-      boolean isInstalledByOtherThread(ControllerContext context)
-      {
-         final InterruptibleControllerTask task = executorTasksByContext.get(context);
-         return task != null && Thread.currentThread() != task.getThread();         
-      }
-      
-      /**
        * Checks in the context is recorded for asynchronous install
        * @param context The context to check
-       * @return true if recorded for asynchronous install
+       * @return the asynchronous install status of the thread
        */
-      boolean isBeingInstalled(ControllerContext context)
+      AsynchronousInstallStatus checkInstalled(ControllerContext context)
       {
-         return executorTasksByContext.get(context) != null;
+         InterruptibleControllerTask task = executorTasksByContext.get(context);
+         if (task == null)
+            return AsynchronousInstallStatus.NOT_INSTALLING;
+         else if (Thread.currentThread() != task.getThread())
+            return AsynchronousInstallStatus.OTHER_THREAD;
+
+         return AsynchronousInstallStatus.IN_PROGRESS;
       }
       
       /**
@@ -2598,7 +2594,18 @@
          }
       }
    }
+   
+   private enum AsynchronousInstallStatus 
+   {
+      /** Context is not being installed asynchronously */ 
+      NOT_INSTALLING,
+      /** Context is being installed asynchronously by another thread */
+      OTHER_THREAD,
+      /** Context is being installed asynchronously by current thread */
+      IN_PROGRESS
+   }
 
+
    // Context queries & registry
 
    public Set<ControllerContext> filter(Iterable<ControllerContext> contexts, ContextFilter filter)




More information about the jboss-cvs-commits mailing list