remm        01/04/06 12:31:20

  Modified:    catalina/src/share/org/apache/catalina/core
                        ApplicationContext.java ContainerBase.java
  Log:
  - Fix for bug 1219. It makes the URLs generated more unique, to avoid confusing
    the JDK's JAR URL cache.
  
  Revision  Changes    Path
  1.19      +20 -14    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
  
  Index: ApplicationContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ApplicationContext.java   2001/03/22 00:51:17     1.18
  +++ ApplicationContext.java   2001/04/06 19:31:17     1.19
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
 1.18 2001/03/22 00:51:17 remm Exp $
  - * $Revision: 1.18 $
  - * $Date: 2001/03/22 00:51:17 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
 1.19 2001/04/06 19:31:17 remm Exp $
  + * $Revision: 1.19 $
  + * $Date: 2001/04/06 19:31:17 $
    *
    * ====================================================================
    *
  @@ -111,7 +111,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.18 $ $Date: 2001/03/22 00:51:17 $
  + * @version $Revision: 1.19 $ $Date: 2001/04/06 19:31:17 $
    */
   
   public final class ApplicationContext
  @@ -160,15 +160,17 @@
           implements PrivilegedExceptionAction {
           
        private String path;
  +        private String host;
        private DirContext resources;
   
  -        PrivilegedGetResource(String path, DirContext resources) {
  +        PrivilegedGetResource(String host, String path, DirContext resources) {
  +            this.host = host;
               this.path = path;
               this.resources = resources;
           }
           
           public Object run() throws Exception {
  -            return new URL("jndi", null, 0, path,
  +            return new URL("jndi", host, 0, path,
                      new DirContextURLStreamHandler(resources));
           }
           
  @@ -185,7 +187,6 @@
        * @param context The associated Context instance
        */
       public ApplicationContext(String basePath, StandardContext context) {
  -
        super();
        this.context = context;
           this.basePath = basePath;
  @@ -495,7 +496,8 @@
            return (null);  
   
        // Construct a RequestDispatcher to process this request
  -     HttpServletRequest hrequest = (HttpServletRequest) request.getRequest();
  +     HttpServletRequest hrequest = 
  +            (HttpServletRequest) request.getRequest();
           return (RequestDispatcher) new ApplicationDispatcher(wrapper,
                           hrequest.getServletPath(), 
                           hrequest.getPathInfo(),    
  @@ -516,22 +518,26 @@
        * @exception MalformedURLException if the path is not given
        *  in the correct form
        */
  -    public URL getResource(String path) throws MalformedURLException {
  +    public URL getResource(String path) 
  +        throws MalformedURLException {
        DirContext resources = context.getResources();
        if (resources != null) {
  +            String fullPath = context.getName() + path;
  +            String hostName = context.getParent().getName();
               try {
                   resources.lookup(path);
                if( System.getSecurityManager() != null ) {
                    try {
                        PrivilegedGetResource dp =
  -                         new PrivilegedGetResource(path,resources);
  +                         new PrivilegedGetResource
  +                                (hostName, fullPath, resources);
                        return (URL)AccessController.doPrivileged(dp);
                    } catch( PrivilegedActionException pe) {
                        throw pe.getException();
                    }
                } else {
  -                    return new URL("jndi", null, 0, path, 
  -                               new DirContextURLStreamHandler(resources));
  +                    return new URL("jndi", hostName, 0, fullPath, 
  +                                   new DirContextURLStreamHandler(resources));
                }
               } catch (Exception e) {
                   //e.printStackTrace();
  @@ -805,8 +811,8 @@
                (ServletContextAttributeListener) listeners[i];
            try {
                if (replaced) {
  -                    context.fireContainerEvent("beforeContextAttributeReplaced",
  -                                               listener);
  +                    context.fireContainerEvent
  +                        ("beforeContextAttributeReplaced", listener);
                    listener.attributeReplaced(event);
                       context.fireContainerEvent("afterContextAttributeReplaced",
                                                  listener);
  
  
  
  1.9       +9 -6      
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ContainerBase.java
  
  Index: ContainerBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ContainerBase.java        2001/01/23 05:05:46     1.8
  +++ ContainerBase.java        2001/04/06 19:31:18     1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v
 1.8 2001/01/23 05:05:46 remm Exp $
  - * $Revision: 1.8 $
  - * $Date: 2001/01/23 05:05:46 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v
 1.9 2001/04/06 19:31:18 remm Exp $
  + * $Revision: 1.9 $
  + * $Date: 2001/04/06 19:31:18 $
    *
    * ====================================================================
    *
  @@ -153,7 +153,7 @@
    * class comments of the implementation class.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.8 $ $Date: 2001/01/23 05:05:46 $
  + * @version $Revision: 1.9 $ $Date: 2001/04/06 19:31:18 $
    */
   
   public abstract class ContainerBase
  @@ -680,8 +680,11 @@
        DirContext oldResources = this.resources;
        if (oldResources == resources)
            return;
  -        this.resources = new ProxyDirContext(new Hashtable(), resources);
  -
  +        Hashtable env = new Hashtable();
  +        if (getParent() != null)
  +            env.put(ProxyDirContext.HOST, getParent().getName());
  +        env.put(ProxyDirContext.CONTEXT, getName());
  +        this.resources = new ProxyDirContext(env, resources);
        // Report this property change to interested listeners
        support.firePropertyChange("resources", oldResources, this.resources);
   
  
  
  

Reply via email to