[jboss-cvs] JBossAS SVN: r61411 - trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Mar 18 12:08:33 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-03-18 12:08:33 -0400 (Sun, 18 Mar 2007)
New Revision: 61411

Modified:
   trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
Log:
JBAS-4206, install first bootstrap ctx class loader as tcl for MainDeployer.process calls

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2007-03-18 05:27:08 UTC (rev 61410)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2007-03-18 16:08:33 UTC (rev 61411)
@@ -22,6 +22,7 @@
 package org.jboss.system.server.profileservice.hotdeploy;
 
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
@@ -34,11 +35,18 @@
 import org.jboss.profileservice.spi.ModificationInfo;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.profileservice.spi.Profile.DeploymentPhase;
 
 
 /**
- * A DeploymentScanner built on the ProfileService and MainDeployer.
+ * A DeploymentScanner built on the ProfileService and MainDeployer. This
+ * is really just a simple ExecutorService Runnable that knows nothing
+ * about how to detect changed deployers. The ProfileService determines
+ * this.
  * 
+ * @see MainDeployer
+ * @see ProfileService
+ * 
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
  * @author Scott.Stark at jboss.org
  * @version $Revision$
@@ -56,10 +64,12 @@
    /** The ExecutorService/ThreadPool for performing scans */
    private ScheduledExecutorService scanExecutor;
    private ScheduledFuture activeScan;
+   /** Thread name used when the ScheduledExecutorService is created internally */
    private String scanThreadName = "HDScanner";
 
    /** Period in ms between deployment scans */
    private long scanPeriod = 5000;
+   /** The number of scans that have been done */
    private int scanCount;
 
    // Constructor ---------------------------------------------------
@@ -222,6 +232,13 @@
       
       // Get the modified deployments
       Profile activeProfile = profileService.getActiveProfile();
+      if( activeProfile == null )
+      {
+         if( trace )
+            log.trace("End deployment scan, no activeProfile");
+         return;
+      }
+
       Collection<ModificationInfo> modified = activeProfile.getModifiedDeployments();
       for(ModificationInfo info : modified)
       {
@@ -244,7 +261,20 @@
       try
       {
          if( modified.size() > 0 )
-            mainDeployer.process();
+         {
+            // Current workaround for JBAS-4206
+            ClassLoader oldTCL = Thread.currentThread().getContextClassLoader();
+            ClassLoader tcl = getTCL(activeProfile);
+            try
+            {
+               Thread.currentThread().setContextClassLoader(tcl);
+               mainDeployer.process();
+            }
+            finally
+            {
+               Thread.currentThread().setContextClassLoader(oldTCL);
+            }
+         }
       }
       catch (Exception e)
       {
@@ -268,5 +298,22 @@
    }
 
    // Private -------------------------------------------------------
-   
+   /**
+    * Current workaround for JBAS-4206
+    */
+   private ClassLoader getTCL(Profile activeProfile)
+      throws Exception
+   {
+      ClassLoader tcl = null;
+      Collection<DeploymentContext> ctxs = activeProfile.getDeployments(DeploymentPhase.BOOTSTRAP);
+      Iterator<DeploymentContext> iter = ctxs.iterator();
+      while( iter.hasNext() )
+      {
+         DeploymentContext ctx = iter.next();
+         tcl = ctx.getClassLoader();
+         if( tcl != null )
+            break;
+      }
+      return tcl;
+   }
 }




More information about the jboss-cvs-commits mailing list