[Jboss-cvs] JBossAS SVN: r55509 - projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 10 20:32:25 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-08-10 20:32:22 -0400 (Thu, 10 Aug 2006)
New Revision: 55509
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java
Log:
JBMICROCONT-100, move the install/uninstall thread context class loader mgt to the common dispatchJoinPoint utility method.
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java 2006-08-10 23:50:37 UTC (rev 55508)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java 2006-08-11 00:32:22 UTC (rev 55509)
@@ -27,9 +27,11 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.dependency.plugins.spi.action.ControllerContextAction;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.joinpoint.spi.Joinpoint;
+import org.jboss.kernel.plugins.config.Configurator;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.logging.Logger;
@@ -53,29 +55,43 @@
*/
protected static Object dispatchJoinPoint(final KernelControllerContext context, final Joinpoint joinpoint) throws Throwable
{
+ BeanMetaData metaData = context.getBeanMetaData();
+ ClassLoader cl = Configurator.getClassLoader(metaData);
AccessControlContext access = null;
if (context instanceof AbstractKernelControllerContext)
{
AbstractKernelControllerContext theContext = (AbstractKernelControllerContext) context;
access = theContext.getAccessControlContext();
}
-
- if (access == null)
+
+ // Dispatch with the bean class loader if it exists
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ try
{
- return joinpoint.dispatch();
- }
- else
- {
- DispatchJoinPoint action = new DispatchJoinPoint(joinpoint);
- try
+ if( cl != null && access == null )
+ Thread.currentThread().setContextClassLoader(cl);
+ if (access == null)
{
- return AccessController.doPrivileged(action, access);
+ return joinpoint.dispatch();
}
- catch (PrivilegedActionException e)
+ else
{
- throw e.getCause();
+ DispatchJoinPoint action = new DispatchJoinPoint(joinpoint);
+ try
+ {
+ return AccessController.doPrivileged(action, access);
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw e.getCause();
+ }
}
}
+ finally
+ {
+ if( cl != null && access == null )
+ Thread.currentThread().setContextClassLoader(tcl);
+ }
}
public void install(final ControllerContext context) throws Throwable
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java 2006-08-10 23:50:37 UTC (rev 55508)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java 2006-08-11 00:32:22 UTC (rev 55509)
@@ -95,9 +95,9 @@
String method = getInstallMethod(context);
List<ParameterMetaData> parameters = getInstallParameters(context);
MethodJoinpoint joinpoint = null;
- ClassLoader cl = Configurator.getClassLoader(metaData);
try
{
+ ClassLoader cl = Configurator.getClassLoader(metaData);
joinpoint = configurator.getMethodJoinPoint(info, cl, method, parameters, false, true);
}
catch (JoinpointException ignored)
@@ -111,21 +111,8 @@
}
return;
}
-
- // Dispatch the joinpoint using the target class loader
joinpoint.setTarget(target);
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- try
- {
- if( cl != null )
- Thread.currentThread().setContextClassLoader(cl);
- dispatchJoinPoint(context, joinpoint);
- }
- finally
- {
- if( cl != null )
- Thread.currentThread().setContextClassLoader(tcl);
- }
+ dispatchJoinPoint(context, joinpoint);
}
public void uninstallAction(KernelControllerContext context)
@@ -142,16 +129,11 @@
String method = getUninstallMethod(context);
List<ParameterMetaData> parameters = getUninstallParameters(context);
MethodJoinpoint joinpoint = null;
- ClassLoader cl = null;
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
try
{
- cl = Configurator.getClassLoader(metaData);
+ ClassLoader cl = Configurator.getClassLoader(metaData);
joinpoint = configurator.getMethodJoinPoint(info, cl, method, parameters, false, true);
joinpoint.setTarget(target);
- // Dispatch the joinpoint using the target class loader
- if( cl != null )
- Thread.currentThread().setContextClassLoader(cl);
dispatchJoinPoint(context, joinpoint);
}
catch (JoinpointException ignored)
@@ -169,10 +151,5 @@
{
log.warn("Error during " + method, throwable);
}
- finally
- {
- if( cl != null )
- Thread.currentThread().setContextClassLoader(tcl);
- }
}
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list