curcuru     01/06/20 12:07:29

  Modified:    java/src/org/apache/xalan/processor
                        TransformerFactoryImpl.java
               java/src/org/apache/xpath/functions FuncSystemProperty.java
  Log:
  Fix resource loading problem in Cocoon.
  Note: this apparently fixes properly the fix that garyp attempted to
  add 21-May-01; however JDK 118 and 122 behave differently when
  calling getResourceAsStream, so in the 118 case I've had to
  prepend a hard-coded / slash char: this should be reviewed later
  PR: email on xalan-dev
  Submitted by: [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.35      +10 -4     
xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java
  
  Index: TransformerFactoryImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- TransformerFactoryImpl.java       2001/06/18 21:42:43     1.34
  +++ TransformerFactoryImpl.java       2001/06/20 19:07:26     1.35
  @@ -112,9 +112,12 @@
   public class TransformerFactoryImpl extends SAXTransformerFactory
   {
   
  -  /** The Xalan properties file. */
  +  /** 
  +   * The path/filename of the property file: XSLTInfo.properties  
  +   * Maintenance note: see also 
org.apache.xpath.functions.FuncSystemProperty.XSLT_PROPERTIES
  +   */
     public static String XSLT_PROPERTIES =
  -    "/org/apache/xalan/res/XSLTInfo.properties";
  +    "org/apache/xalan/res/XSLTInfo.properties";
   
     /** Flag tells if the properties file has been loaded to the system */
     private static boolean isInited = false;
  @@ -164,13 +167,16 @@
               java.lang.reflect.Method getCCL = 
Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
               if (getCCL != null) {
                 ClassLoader contextClassLoader = (ClassLoader) 
getCCL.invoke(Thread.currentThread(), NO_OBJS);
  -              is = 
contextClassLoader.getResourceAsStream("org/apache/xalan/processor/" + file);
  +              is = contextClassLoader.getResourceAsStream(file); // file 
should be already fully specified
               }
             }
             catch (Exception e) {}
   
             if (is == null) {
  -            is = TransformerFactoryImpl.class.getResourceAsStream(file);
  +            // NOTE! For the below getResourceAsStream in Sun JDK 1.1.8M
  +            //  we apparently must add the leading slash character - I 
  +            //  don't know why, but if it's not there, we throw an NPE from 
the below loading
  +            is = TransformerFactoryImpl.class.getResourceAsStream("/" + 
file); // file should be already fully specified
             }
   
             // get a buffered version
  
  
  
  1.11      +14 -7     
xml-xalan/java/src/org/apache/xpath/functions/FuncSystemProperty.java
  
  Index: FuncSystemProperty.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncSystemProperty.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FuncSystemProperty.java   2001/06/12 19:16:38     1.10
  +++ FuncSystemProperty.java   2001/06/20 19:07:27     1.11
  @@ -83,8 +83,11 @@
   public class FuncSystemProperty extends FunctionOneArg
   {
   
  -  /** The name of the property file where the name will be stored.  */
  -  static String XSLT_PROPERTIES = 
"/org/apache/xalan/res/XSLTInfo.properties";
  +  /** 
  +   * The path/filename of the property file: XSLTInfo.properties  
  +   * Maintenance note: see also 
org.apache.xalan.processor.TransformerFactoryImpl.XSLT_PROPERTIES
  +   */
  +  static String XSLT_PROPERTIES = "org/apache/xalan/res/XSLTInfo.properties";
        
        /** a zero length Class array used in loadPropertyFile() */
     private static final Class[] NO_CLASSES = new Class[0];
  @@ -205,8 +208,8 @@
     /**
      * Retrieve a propery bundle from a specified file
      * 
  -   * @param file The string name of the property file.  The file is loaded 
from 
  -   *             the workplace base directory
  +   * @param file The string name of the property file.  The name 
  +   * should already be fully qualified as path/filename
      * @param target The target property bag the file will be placed into.
      */
     public void loadPropertyFile(String file, Properties target)
  @@ -220,13 +223,17 @@
           java.lang.reflect.Method getCCL = 
Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
           if (getCCL != null) {
             ClassLoader contextClassLoader = (ClassLoader) 
getCCL.invoke(Thread.currentThread(), NO_OBJS);
  -          is = 
contextClassLoader.getResourceAsStream("org/apache/xpath/functions/" + file);
  +          is = contextClassLoader.getResourceAsStream(file); // file should 
be already fully specified
           }
         }
         catch (Exception e) {}
   
  -      if (is == null);
  -        is = FuncSystemProperty.class.getResourceAsStream(file);
  +      if (is == null) {
  +        // NOTE! For the below getResourceAsStream in Sun JDK 1.1.8M
  +        //  we apparently must add the leading slash character - I 
  +        //  don't know why, but if it's not there, we throw an NPE from the 
below loading
  +        is = FuncSystemProperty.class.getResourceAsStream("/" + file); // 
file should be already fully specified
  +      }
   
         // get a buffered version
         BufferedInputStream bis = new BufferedInputStream(is);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to