jvanzyl     01/08/28 19:37:27

  Modified:    src/java/org/apache/velocity/texen/ant TexenTask.java
  Log:
  - allow a specified context properties resource to be found on the
    classpath.
  
  Revision  Changes    Path
  1.29      +25 -6     
jakarta-velocity/src/java/org/apache/velocity/texen/ant/TexenTask.java
  
  Index: TexenTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/texen/ant/TexenTask.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- TexenTask.java    2001/08/29 01:46:31     1.28
  +++ TexenTask.java    2001/08/29 02:37:27     1.29
  @@ -63,6 +63,8 @@
   import java.io.FileWriter;
   import java.io.FileOutputStream;
   import java.io.FileInputStream;
  +import java.io.InputStream;
  +import java.io.IOException;
   
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Task;
  @@ -84,7 +86,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="[EMAIL PROTECTED]">Robert Burrell Donkin</a>
  - * @version $Id: TexenTask.java,v 1.28 2001/08/29 01:46:31 jvanzyl Exp $
  + * @version $Id: TexenTask.java,v 1.29 2001/08/29 02:37:27 jvanzyl Exp $
    */
   public class TexenTask 
       extends Task
  @@ -254,17 +256,34 @@
        * fed into the initial context be the
        * generating process starts.
        */
  -    public void setContextProperties( File file )
  +    public void setContextProperties( String file )
       {
           contextProperties = new ExtendedProperties();
           
  -        try
  +        if (useClasspath)
           {
  -            contextProperties.load(new FileInputStream(file));
  +            ClassLoader classLoader = this.getClass().getClassLoader();
  +            
  +            try
  +            {
  +                InputStream inputStream = classLoader.getResourceAsStream(file);
  +                contextProperties.load(inputStream);
  +            }
  +            catch (IOException ioe)
  +            {
  +                contextProperties = null;
  +            }
           }
  -        catch (Exception e)
  +        else
           {
  -            contextProperties = null;
  +            try
  +            {
  +                contextProperties.load(new FileInputStream(file));
  +            }
  +            catch (Exception e)
  +            {
  +                contextProperties = null;
  +            }
           }
       }
   
  
  
  

Reply via email to