Examples of VelocityEngine


Examples of org.apache.velocity.app.VelocityEngine

     * @param config servlet configuation
     */
    protected void init(ServletConfig config)
    {
        // initialize a new VelocityEngine
        init(config, new VelocityEngine());

        // initialize a new ToolboxFactory
        init(config, new ToolboxFactory());

        // set encoding & content-type
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

        if (context == null) {
            throw new IllegalStateException("context was not set");
        }

        // setup velocity
        VelocityEngine velocity = new VelocityEngine();
        velocity.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, sourceDir.getAbsolutePath());
        velocity.init();

        List plans = new LinkedList();
        findPlans(sourceDir, plans);
        for (Iterator iterator = plans.iterator(); iterator.hasNext();) {
            File plan = (File) iterator.next();
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

            if (targetFile == null) {
                throw new RuntimeException("No target plan supplied");
            }

            File sourceD = new File(sourceDir);
            VelocityEngine velocity = new VelocityEngine();
            velocity.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, sourceD.getAbsolutePath());
            velocity.init();
            Template template = velocity.getTemplate(planFile);
            StringWriter writer = new StringWriter();
            template.merge(context, writer);

            String plan = writer.toString();
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

        //        Might be better of just hand rolling something...
        //

        VelocityContext context = createContext();

        VelocityEngine velocity = new VelocityEngine();
        velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, sourceDir.getAbsolutePath());

        // Don't spit out any logs
        velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.NullLogSystem");
        velocity.init();

        Template template = velocity.getTemplate(planFileName);
        StringWriter writer = new StringWriter();
        template.merge(context, writer);

        String plan = writer.toString();
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

      }
    } catch (Exception e) {
      throw new BuildException(e);
    }
   
    VelocityEngine ve = new VelocityEngine();

    try {
      ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, getTemplatePath());
      if (logFile != null) {
        File lf = new File(logFile);
        if (lf.exists()) {
          if (!lf.delete()) {
            throw new Exception("Could not delete log file " + lf.getCanonicalPath());
          }
        }

        ve.setProperty(RuntimeConstants.RUNTIME_LOG, logFile);
      }

      ve.init();
      Template t = ve.getTemplate(template);

      if (clusterMode == null) {
        clusterMode = new String("");
      }
      if (hadoopVersion == null) {
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

                "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
       
        try
        {           
            _properties.setProperty(VELOCITY_FILE_RESOURCE_LOADER_PATH, dir.getCanonicalPath());           
            _engine = new VelocityEngine(_properties);           
        }
        catch(Exception e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

  public synchronized final static TemplateManager getInstance(ServletContext servletContext) {
    return new TemplateManager(servletContext);
  }

  private TemplateManager(ServletContext servletContext) {
    engine = new VelocityEngine();
    engine.setProperty("resource.loader", "webapp");
    engine.setProperty("webapp.resource.loader.class", "org.apache.velocity.tools.view.WebappResourceLoader");
    engine.setProperty("webapp.resource.loader.path", "/WEB-INF/templates/");
    engine.setApplicationAttribute("javax.servlet.ServletContext", servletContext);
  }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

        super(name);
    }

    public void setUp() throws Exception
    {
        engine = new VelocityEngine();

        //by default, make the engine's log output go to the test-report
        log = new TestLogChute(false, false);
        log.setEnabledLevel(TestLogChute.INFO_ID);
        log.setSystemErrLevel(TestLogChute.WARN_ID);
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

    }
    catch (Exception e) {
      throw new BuildException(e);
    }
   
    VelocityEngine ve = new VelocityEngine();

    try {
      ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templatePath);
      if (logFile != null) {
        File lf = new File(logFile);
        if (lf.exists()) {
          if (!lf.delete()) {
            throw new Exception("Could not delete log file " + lf.getCanonicalPath());
          }
        }

        ve.setProperty(RuntimeConstants.RUNTIME_LOG, logFile);
      }

      ve.init();
      Template t = ve.getTemplate(template);

      // For each of the qFiles generate the test
      VelocityContext ctx = new VelocityContext();
      ctx.put("className", className);
      ctx.put("qfiles", qFiles);
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

        initializeClassTemplate(template);
    }

    private void initializeClassTemplate(String template) throws Exception {
        VelocityEngine velocityEngine = new VelocityEngine();
        try {

            // use ClasspathResourceLoader for velocity templates lookup
            // if Cayenne URL is not null, load resource from this URL
            Properties props = new Properties();

            // null logger that will prevent velocity.log from being generated
            props.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogSystem.class
                    .getName());

            props.put("resource.loader", "cayenne");

            props.put(
                    "cayenne.resource.loader.class",
                    "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

            velocityEngine.init(props);
        }
        catch (Exception ex) {
            throw new RuntimeException("Can't initialize Velocity", ex);
        }

        pageTemplate = velocityEngine.getTemplate(template);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.