tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardWrapper.java
Date Wed, 09 May 2001 06:56:16 GMT
remm        01/05/08 23:56:16

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardWrapper.java
  Log:
  - Set context class loader during init / destroy.
    Based on a patch submitted by Kyle F. Downey <kdowney at amberarcher.com>
  
  Revision  Changes    Path
  1.20      +21 -7     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java
  
  Index: StandardWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- StandardWrapper.java	2001/04/25 02:20:48	1.19
  +++ StandardWrapper.java	2001/05/09 06:56:14	1.20
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
1.19 2001/04/25 02:20:48 craigmcc Exp $
  - * $Revision: 1.19 $
  - * $Date: 2001/04/25 02:20:48 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
1.20 2001/05/09 06:56:14 remm Exp $
  + * $Revision: 1.20 $
  + * $Date: 2001/05/09 06:56:14 $
    *
    * ====================================================================
    *
  @@ -104,7 +104,7 @@
    * make them efficient are counter-productive.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.19 $ $Date: 2001/04/25 02:20:48 $
  + * @version $Revision: 1.20 $ $Date: 2001/05/09 06:56:14 $
    */
   
   public final class StandardWrapper
  @@ -759,6 +759,9 @@
   	    throw new ServletException
   		(sm.getString("standardWrapper.missingLoader", getName()));
   	}
  +
  +        ClassLoader oldCtxClassLoader = 
  +            Thread.currentThread().getContextClassLoader();
   	ClassLoader classLoader = loader.getClassLoader();
   
           // Special case class loader for a Catalina internal servlet
  @@ -811,6 +814,7 @@
   	try {
   	    instanceSupport.fireInstanceEvent(InstanceEvent.BEFORE_INIT_EVENT,
   					      servlet);
  +            Thread.currentThread().setContextClassLoader(classLoader);
   	    servlet.init((ServletConfig) this);
   	    instanceSupport.fireInstanceEvent(InstanceEvent.AFTER_INIT_EVENT,
   					      servlet);
  @@ -832,7 +836,10 @@
   	    // said so, so do not call unavailable(null).
   	    throw new ServletException
   		(sm.getString("standardWrapper.initException", getName()), f);
  -	}
  +	} finally {
  +            // restore the context ClassLoader
  +            Thread.currentThread().setContextClassLoader(oldCtxClassLoader);
  +        }
   
   	// Register our newly initialized instance
   	instance = servlet;
  @@ -959,12 +966,16 @@
                   }
               }
           }
  -              
  +        
  +        ClassLoader oldCtxClassLoader = 
  +            Thread.currentThread().getContextClassLoader();
  +        ClassLoader classLoader = loader.getClassLoader();
   
   	// Call the servlet destroy() method
   	try {
   	    instanceSupport.fireInstanceEvent
   	      (InstanceEvent.BEFORE_DESTROY_EVENT, instance);
  +            Thread.currentThread().setContextClassLoader(classLoader);
   	    instance.destroy();
   	    instanceSupport.fireInstanceEvent
   	      (InstanceEvent.AFTER_DESTROY_EVENT, instance);
  @@ -977,7 +988,10 @@
   	    throw new ServletException
   		(sm.getString("standardWrapper.destroyException", getName()),
   		 t);
  -	}
  +	} finally {
  +            // restore the context ClassLoader
  +            Thread.currentThread().setContextClassLoader(oldCtxClassLoader);
  +        }
   
   	// Deregister the destroyed instance
   	instance = null;
  
  
  

Mime
View raw message