greenrd     01/02/05 10:41:54

  Modified:    .        changes.xml
               src/org/apache/cocoon Utils.java
  Log:
  fixed getLocationResource
  
  Revision  Changes    Path
  1.205     +5 -1      xml-cocoon/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/changes.xml,v
  retrieving revision 1.204
  retrieving revision 1.205
  diff -u -r1.204 -r1.205
  --- changes.xml       2001/02/01 21:02:47     1.204
  +++ changes.xml       2001/02/05 18:41:47     1.205
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes   
  -  $Id: changes.xml,v 1.204 2001/02/01 21:02:47 greenrd Exp $ 
  +  $Id: changes.xml,v 1.205 2001/02/05 18:41:47 greenrd Exp $ 
   -->
   
   <changes title="History of Changes">
  @@ -18,6 +18,10 @@
     </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="RDG" type="fix">
  +   Fixed Utils.getLocationResource to use parent ClassLoader instead of 
System ClassLoader, but
  +   fallback to System if resource not found.
  +  </action>
     <action dev="RDG" type="fix" due-to="Sebastien Koechlin" 
due-to-email="[EMAIL PROTECTED]">
      Reversed change in 1.8.1 that ignored query string for XSLTProcessor 
caching
     </action>
  
  
  
  1.24      +9 -13     xml-cocoon/src/org/apache/cocoon/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Utils.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Utils.java        2001/01/19 00:23:48     1.23
  +++ Utils.java        2001/02/05 18:41:52     1.24
  @@ -1,4 +1,4 @@
  -/*-- $Id: Utils.java,v 1.23 2001/01/19 00:23:48 greenrd Exp $ --
  +/*-- $Id: Utils.java,v 1.24 2001/02/05 18:41:52 greenrd Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -66,7 +66,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Robin Green</a>
  - * @version $Revision: 1.23 $ $Date: 2001/01/19 00:23:48 $
  + * @version $Revision: 1.24 $ $Date: 2001/02/05 18:41:52 $
    */
   
   public final class Utils {
  @@ -335,8 +335,11 @@
           if (location.indexOf("://") < 0) {
               resource = new File(location);
           } else if (location.startsWith("resource://")) {
  -            // FIXME (SM): this should _not_ be system resource, but rather 
a resource of current classloader
  -            resource = 
ClassLoader.getSystemResource(location.substring("resource://".length()));
  +            String res = location.substring("resource://".length());
  +            resource = getClass ().getClassLoader ().getResource (res);
  +            if (resource == null) {
  +              resource = ClassLoader.getSystemResource(res);
  +            }
           } else {
               resource = new URL(location);
           }
  @@ -348,8 +351,6 @@
        * Returns the resource pointed by the given location relative to the 
given request.
        */
       public static final Object getLocationResource(String location, 
HttpServletRequest request, ServletContext context) throws Exception {
  -        Object resource = null;
  -        
           if (location.indexOf("://") < 0) {
               if (location.charAt(0) == '/') {
                   // Location is relative to webserver's root
  @@ -359,13 +360,8 @@
                   String basename = getBasename(request, context);
                   location = basename.substring(0, basename.lastIndexOf('/') + 
1) + location;
               }
  -            resource = new File(location);
  -        } else if (location.startsWith("resource://")) {
  -            // FIXME (SM): this should _not_ be system resource, but rather 
a resource of current classloader
  -            resource = 
ClassLoader.getSystemResource(location.substring("resource://".length()));
  -        } else {
  -            resource = new URL(location);
  -        }
  +            return new File(location);
  +        } else return getLocationResource (location);
           
           return resource;
       }
  
  
  

Reply via email to