View Javadoc

1   package org.codehaus.xfire.xmlbeans.generator;
2   
3   import java.io.Reader;
4   import java.io.Writer;
5   
6   import org.apache.velocity.VelocityContext;
7   import org.apache.velocity.app.VelocityEngine;
8   
9   /***
10   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
11   * @since Nov 2, 2004
12   */
13  public class VelocityGenerationStrategy
14  {
15      private static VelocityEngine engine = new VelocityEngine();
16      
17      static
18      {
19          engine.addProperty("runtime.log.logsystem.log4j.category", "velocity");
20          try
21          {
22              engine.init();
23          }
24          catch (Exception e)
25          {
26              e.printStackTrace();
27          }
28      }
29  
30      protected void generateStub(VelocityContext context, Writer writer, Reader template) 
31          throws Exception
32      {        
33          engine.evaluate( context, writer, "", template );
34          writer.flush();
35      }
36  }