You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jv...@apache.org on 2002/07/25 00:42:51 UTC

cvs commit: jakarta-velocity/src/java/org/apache/velocity/texen/ant TexenTask.java Texen.java

jvanzyl     2002/07/24 15:42:51

  Modified:    src/java/org/apache/velocity/texen Generator.java
               src/java/org/apache/velocity/texen/ant TexenTask.java
  Removed:     src/java/org/apache/velocity/texen/ant Texen.java
  Log:
  o converting texen over to using VelocityEngine instead of the singleton as
    it was causing no end of grief in Maven when being called multiple
    times within the same goal. Texen was getting very confused. This is
    the way it should have been done a while ago. All tests pass, let me
    know if you experience any problems.
  
  Revision  Changes    Path
  1.20      +18 -5     jakarta-velocity/src/java/org/apache/velocity/texen/Generator.java
  
  Index: Generator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/texen/Generator.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Generator.java	6 Dec 2001 07:46:47 -0000	1.19
  +++ Generator.java	24 Jul 2002 22:42:51 -0000	1.20
  @@ -73,7 +73,7 @@
   import org.apache.velocity.Template;
   import org.apache.velocity.context.Context;
   import org.apache.velocity.VelocityContext;
  -import org.apache.velocity.app.Velocity;
  +import org.apache.velocity.app.VelocityEngine;
   
   /**
    * A text/code generator class
  @@ -137,6 +137,11 @@
        * (templates).
        */
       protected String inputEncoding;
  +    
  +    /**
  +     * Velocity engine.
  +     */
  +    protected VelocityEngine ve;
   
       /**
        * Default constructor.
  @@ -157,6 +162,14 @@
       }
       
       /**
  +     * Set the velocity engine.
  +     */
  +    public void setVelocityEngine(VelocityEngine ve)
  +    {
  +        this.ve = ve;
  +    }        
  +
  +    /**
        * Create a new generator object with properties loaded from
        * a file.  If the file does not exist or any other exception
        * occurs during the reading operation the default properties
  @@ -208,7 +221,7 @@
        */
       protected void setDefaultProps()
       {
  -        ClassLoader classLoader = Velocity.class.getClassLoader();
  +        ClassLoader classLoader = VelocityEngine.class.getClassLoader();
           try
           {
               InputStream inputStream = null;
  @@ -318,10 +331,10 @@
       public Template getTemplate(String templateName, String encoding) throws Exception {
           Template template;
           if (encoding == null || encoding.length() == 0 || encoding.equals("8859-1") || encoding.equals("8859_1")) {
  -            template = Velocity.getTemplate(templateName);
  +            template = ve.getTemplate(templateName);
           }
           else {
  -            template = Velocity.getTemplate(templateName, encoding);
  +            template = ve.getTemplate(templateName, encoding);
           }
           return template;
       }
  
  
  
  1.38      +21 -16    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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- TexenTask.java	6 Dec 2001 07:46:47 -0000	1.37
  +++ TexenTask.java	24 Jul 2002 22:42:51 -0000	1.38
  @@ -69,7 +69,7 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Task;
   import org.apache.velocity.VelocityContext;
  -import org.apache.velocity.app.Velocity;
  +import org.apache.velocity.app.VelocityEngine;
   import org.apache.velocity.context.Context;
   import org.apache.velocity.texen.Generator;
   import org.apache.velocity.util.StringUtils;
  @@ -217,7 +217,9 @@
                   resolvedPath.append(",");
               }
           }
  -         this.templatePath = resolvedPath.toString();
  +        this.templatePath = resolvedPath.toString();
  +        
  +        System.out.println(templatePath);
        }
   
       /**
  @@ -419,40 +421,43 @@
           {
               throw new BuildException("The output file needs to be defined!");
           }            
  -
  +        
  +        VelocityEngine ve = new VelocityEngine();
  +        
           try
           {
               // Setup the Velocity Runtime.
               if (templatePath != null)
               {
               	log("Using templatePath: " + templatePath, project.MSG_VERBOSE);
  -                Velocity.setProperty(
  -                    Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
  +                ve.setProperty(
  +                    ve.FILE_RESOURCE_LOADER_PATH, templatePath);
               }
               
               if (useClasspath)
               {
               	log("Using classpath");
  -                Velocity.addProperty(
  -                    Velocity.RESOURCE_LOADER, "classpath");
  +                ve.addProperty(
  +                    VelocityEngine.RESOURCE_LOADER, "classpath");
               
  -                Velocity.setProperty(
  -                    "classpath." + Velocity.RESOURCE_LOADER + ".class",
  -                        "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
  +                ve.setProperty(
  +                    "classpath." + VelocityEngine.RESOURCE_LOADER + ".class",
  +                        "org.apache.VelocityEngine.runtime.resource.loader.ClasspathResourceLoader");
   
  -                Velocity.setProperty(
  -                    "classpath." + Velocity.RESOURCE_LOADER + 
  +                ve.setProperty(
  +                    "classpath." + VelocityEngine.RESOURCE_LOADER + 
                           ".cache", "false");
   
  -                Velocity.setProperty(
  -                    "classpath." + Velocity.RESOURCE_LOADER + 
  +                ve.setProperty(
  +                    "classpath." + VelocityEngine.RESOURCE_LOADER + 
                           ".modificationCheckInterval", "2");
               }
               
  -            Velocity.init();
  +            ve.init();
   
               // Create the text generator.
               Generator generator = Generator.getInstance();
  +            generator.setVelocityEngine(ve);
               generator.setOutputPath(outputDirectory);
               generator.setInputEncoding(inputEncoding);
               generator.setOutputEncoding(outputEncoding);
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-velocity/src/java/org/apache/velocity/texen/ant TexenTask.java Texen.java

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 7/24/02 6:42 PM, "jvanzyl@apache.org" <jv...@apache.org> wrote:

> jvanzyl     2002/07/24 15:42:51
> 
> Modified:    src/java/org/apache/velocity/texen Generator.java
>              src/java/org/apache/velocity/texen/ant TexenTask.java
> Removed:     src/java/org/apache/velocity/texen/ant Texen.java
> Log:
> o converting texen over to using VelocityEngine instead of the singleton as
>   it was causing no end of grief in Maven when being called multiple
>   times within the same goal. Texen was getting very confused. This is
>   the way it should have been done a while ago. All tests pass, let me
>   know if you experience any problems.
>

Heh.  About time :)

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: cvs commit: jakarta-velocity/src/java/org/apache/velocity/texen/ant TexenTask.java Texen.java

Posted by Stephen Haberman <st...@chase3000.com>.
Any chance while you're working on Texen you can look at the
PropertiesUtil patch I posted a week ago or so and give it a +/- 1? 

Thanks,
Stephen

> -----Original Message-----
> From: jvanzyl@apache.org [mailto:jvanzyl@apache.org]
> Sent: Wednesday, July 24, 2002 5:43 PM
> To: jakarta-velocity-cvs@apache.org
> Subject: cvs commit:
jakarta-velocity/src/java/org/apache/velocity/texen/ant
> TexenTask.java Texen.java
> 
> jvanzyl     2002/07/24 15:42:51
> 
>   Modified:    src/java/org/apache/velocity/texen Generator.java
>                src/java/org/apache/velocity/texen/ant TexenTask.java
>   Removed:     src/java/org/apache/velocity/texen/ant Texen.java
>   Log:
>   o converting texen over to using VelocityEngine instead of the
singleton as
>     it was causing no end of grief in Maven when being called multiple
>     times within the same goal. Texen was getting very confused. This
is
>     the way it should have been done a while ago. All tests pass, let
me
>     know if you experience any problems.
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>