Package org.apache.velocity.app

Examples of org.apache.velocity.app.VelocityEngine


            if ( !f.getParentFile().exists() )
            {
                f.getParentFile().mkdirs();
            }

            VelocityEngine engine = velocity.getEngine();

            engine.setApplicationAttribute( "baseDirectory", basedir );

            if ( StringUtils.isEmpty( templateEncoding ) )
            {
                templateEncoding =  ReaderFactory.FILE_ENCODING;
                getLog().warn(
                               "File encoding has not been set, using platform encoding " + templateEncoding
                                   + ", i.e. build is platform dependent!" );
            }

            Writer writer = new OutputStreamWriter( new FileOutputStream( f ), templateEncoding );

            Template velocityTemplate = engine.getTemplate( templateDirectory + "/" + template, templateEncoding );

            velocityTemplate.merge( context, writer );

            writer.flush();
View Full Code Here


  }

  private static String logChuteName = null;

  private void initializeVelocity() {
    this.velocityEngine = new VelocityEngine();

    // These  properties tell Velocity to use its own classpath-based
    // loader, then drop down to check the root and the current folder
    velocityEngine.addProperty("resource.loader", "class, file");
    velocityEngine.addProperty("class.resource.loader.class",
View Full Code Here

            props.put("resource.loader", "cayenne");
            props.put("cayenne.resource.loader.class", ClassGeneratorResourceLoader.class
                    .getName());
            props.put("cayenne.resource.loader.cache", "false");

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine.init(props);

            template = velocityEngine.getTemplate(templateName);
            templateCache.put(templateName, template);
        }

        return template;
    }
View Full Code Here

      }

      this.configMap = map;

      // Initialise velocity engine
      this.ve = new VelocityEngine();

      this.ve.setProperty("runtime.log.logsystem.class",
                             "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
      this.ve.setProperty("runtime.log.logsystem.log4j.category",
                             log.getName() + ".VelocityEngine");
View Full Code Here

            Map<String, Object> dataModel, MediaType mediaType) {
        super(mediaType);

        try {
            setDataModel(dataModel);
            this.engine = new VelocityEngine();
            this.template = null;
            this.templateName = templateName;
        } catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

  public VelocityServletSerializer() {
    try {
          Properties properties = PropertiesUtils.getProperties(getPropertiesName());
          properties.setProperty("resource.loader", "classpath");
          properties.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
          velocityEngine = new VelocityEngine(properties);
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage(), e);
    }
View Full Code Here

    /** @see Reporter */
    public void end()
        throws Exception {

        VelocityEngine engine = new VelocityEngine();
        engine.init();

        VelocityContext ctx = new VelocityContext();

        ctx.put("root", root);
        ctx.put("names", names);
        ctx.put("values", values);

        StringWriter writer = new StringWriter();

        if (engine.mergeTemplate(template, ctx, writer) != true) {
            throw new Exception("Error processing template");
        }

        writer.flush();

View Full Code Here

            throw new RuntimeException(ex);
        }
    }

    private static VelocityEngine createEngine() {
        VelocityEngine ret = new VelocityEngine();

        return ret;
    }
View Full Code Here

  private VelocityEngine velocityEngine;

  public VelocityListingsPage() {
    try {
      Properties props = PropertyUtils.getProperties("velocity.properties");
      velocityEngine = new VelocityEngine();
      velocityEngine.setProperty("resource.loader", "list");
      velocityEngine.init(props);
    } catch (Exception e) {
      LOG.warn(e.getMessage());
    }
View Full Code Here

import org.apache.velocity.runtime.RuntimeConstants;

public class Velocity_test {

  public static void main(String[] args) throws Exception {
    VelocityEngine ve = new VelocityEngine();//PropertyUtils.getProperties("server.properties"));
    ve.setProperty("error.resource.loader.class",
      //"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
      "org.apache.velocity.runtime.resource.loader.URLResourceLoader");
    ve.setProperty(
      RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
            "org.apache.velocity.runtime.log.Log4JLogChute");
    ve.setProperty("runtime.log.logsystem.log4j.logger", "org.tamacat.Test");
    ve.init();
    System.out.println(ve.getTemplate("htdocs/web/index.vm").getData());
  }
View Full Code Here

TOP

Related Classes of org.apache.velocity.app.VelocityEngine

Copyright © 2018 www.massapicom. 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.