User: starksm
Date: 01/10/02 23:26:01
Modified: src/main/org/jboss/web Tag: Branch_2_4
AbstractWebContainer.java
Log:
Create a unique class loader for every war deployment to ensure that
the war receives a unique ENC regardless if the integrated container
creates a class loader for the war.
Revision Changes Path
No revision
No revision
1.4.4.3 +17 -3 jboss/src/main/org/jboss/web/AbstractWebContainer.java
Index: AbstractWebContainer.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/web/AbstractWebContainer.java,v
retrieving revision 1.4.4.2
retrieving revision 1.4.4.3
diff -u -r1.4.4.2 -r1.4.4.3
--- AbstractWebContainer.java 2001/09/28 19:20:01 1.4.4.2
+++ AbstractWebContainer.java 2001/10/03 06:26:00 1.4.4.3
@@ -2,6 +2,7 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Iterator;
import javax.naming.Context;
@@ -112,8 +113,8 @@
@see org.jboss.security.SimplePrincipal;
@see org.jboss.security.SecurityAssociation;
-@author [EMAIL PROTECTED]
-@version $Revision: 1.4.4.2 $
+@author [EMAIL PROTECTED]
+@version $Revision: 1.4.4.3 $
*/
public abstract class AbstractWebContainer extends ServiceMBeanSupport implements
AbstractWebContainerMBean
{
@@ -156,12 +157,16 @@
perform the container specific deployment steps and registers the
returned WebApplication in the deployment map. The steps performed are:
+ ClassLoader appClassLoader = thread.getContextClassLoader();
+ URLClassLoader warLoader = URLClassLoader.newInstance(empty,
appClassLoader);
+ thread.setContextClassLoader(warLoader);
WebDescriptorParser webAppParser = ...;
WebApplication warInfo = performDeploy(ctxPath, warUrl, webAppParser);
ClassLoader loader = warInfo.getClassLoader();
Element webApp = warInfo.getWebApp();
Element jbossWeb = warInfo.getJbossWeb();
deploymentMap.put(warUrl, warInfo);
+ thread.setContextClassLoader(appClassLoader);
The subclass performDeploy() implementation needs to invoke
webAppParser.parseWebAppDescriptors(loader, webApp, jbossWeb) to have the
@@ -175,14 +180,19 @@
*/
public synchronized void deploy(String ctxPath, String warUrl) throws
DeploymentException
{
+ Thread thread = Thread.currentThread();
+ ClassLoader appClassLoader = thread.getContextClassLoader();
try
{
+ // Create a classloader for the war to ensure a unique ENC
+ URL[] empty = {};
+ URLClassLoader warLoader = URLClassLoader.newInstance(empty,
appClassLoader);
+ thread.setContextClassLoader(warLoader);
WebDescriptorParser webAppParser = new DescriptorParser();
WebApplication warInfo = performDeploy(ctxPath, warUrl, webAppParser);
ClassLoader loader = warInfo.getClassLoader();
Element webApp = warInfo.getWebApp();
Element jbossWeb = warInfo.getJbossWeb();
- //parseWebAppDescriptors(loader, webApp, jbossWeb);
deploymentMap.put(warUrl, warInfo);
}
catch(DeploymentException e)
@@ -193,6 +203,10 @@
{
e.printStackTrace();
throw new DeploymentException("Error during deploy", e);
+ }
+ finally
+ {
+ thread.setContextClassLoader(appClassLoader);
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development