[jboss-cvs] JBossAS SVN: r61365 - projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/plugins/deployment.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Mar 16 01:45:17 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-03-16 01:45:17 -0400 (Fri, 16 Mar 2007)
New Revision: 61365

Modified:
   projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
Log:
Look to the unit class loader and then the deployer class loader to setup the tcl for deploy/undeploy

Modified: projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2007-03-16 04:52:19 UTC (rev 61364)
+++ projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2007-03-16 05:45:17 UTC (rev 61365)
@@ -514,7 +514,26 @@
    private void prepareUndeploy(Deployer deployer, DeploymentContext context, boolean doComponents)
    {
       DeploymentUnit unit = context.getDeploymentUnit();
-      deployer.prepareUndeploy(unit);
+      ClassLoader oldTCL = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         ClassLoader tcl = null;
+         try
+         {
+            tcl = unit.getClassLoader();
+         }
+         catch(Exception e)
+         {
+         }
+         if( tcl == null )
+            tcl = deployer.getClass().getClassLoader();
+         Thread.currentThread().setContextClassLoader(tcl);
+         deployer.prepareUndeploy(unit);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldTCL);
+      }
       
       if (doComponents)
       {
@@ -530,7 +549,26 @@
    private void commitUndeploy(Deployer deployer, DeploymentContext context, boolean doComponents)
    {
       DeploymentUnit unit = context.getDeploymentUnit();
-      deployer.commitUndeploy(unit);
+      ClassLoader oldTCL = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         ClassLoader tcl = null;
+         try
+         {
+            tcl = unit.getClassLoader();
+         }
+         catch(Exception e)
+         {
+         }
+         if( tcl == null )
+            tcl = deployer.getClass().getClassLoader();
+         Thread.currentThread().setContextClassLoader(tcl);
+         deployer.commitUndeploy(unit);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldTCL);
+      }
       
       if (doComponents)
       {
@@ -552,7 +590,26 @@
          theComponents = components.toArray(new DeploymentContext[components.size()]);
       
       DeploymentUnit unit = context.getDeploymentUnit();
-      deployer.prepareDeploy(unit);
+      ClassLoader oldTCL = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         ClassLoader tcl = null;
+         try
+         {
+            tcl = unit.getClassLoader();
+         }
+         catch(Exception e)
+         {
+         }
+         if( tcl == null )
+            tcl = deployer.getClass().getClassLoader();
+         Thread.currentThread().setContextClassLoader(tcl);
+         deployer.prepareDeploy(unit);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldTCL);
+      }
 
       try
       {
@@ -589,7 +646,26 @@
          theComponents = components.toArray(new DeploymentContext[components.size()]);
       
       DeploymentUnit unit = context.getDeploymentUnit();
-      deployer.commitDeploy(unit);
+      ClassLoader oldTCL = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         ClassLoader tcl = null;
+         try
+         {
+            tcl = unit.getClassLoader();
+         }
+         catch(Exception e)
+         {
+         }
+         if( tcl == null )
+            tcl = deployer.getClass().getClassLoader();
+         Thread.currentThread().setContextClassLoader(tcl);
+         deployer.commitDeploy(unit);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldTCL);
+      }
 
       try
       {




More information about the jboss-cvs-commits mailing list