Examples of VelocityEngine


Examples of org.apache.velocity.app.VelocityEngine

   
    if (testOutputDirectory != null && !testOutputDirectory.exists()) {
      testOutputDirectory.mkdirs();
    }

    VelocityEngine mainVelocityEngine = new VelocityEngine();
    mainVelocityEngine.setProperty("file.resource.loader.path", sourceTemplateRoot);
    if (testTemplateRoot != null) {
      testVelocityEngine = new VelocityEngine();
      testVelocityEngine.setProperty("file.resource.loader.path", testTemplateRoot);
    }

   
    try {
      mainVelocityEngine.init();
      if (testVelocityEngine != null) {
        testVelocityEngine.init();
      }
    } catch (Exception e) {
      throw new MojoExecutionException("Unable to initialize velocity", e);
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

            for (Map.Entry<String, Object> entry : context.entrySet()) {
              vcontext.put(entry.getKey(), entry.getValue());
            }
          }
            StringWriter writer = new StringWriter();
            VelocityEngine ve = new VelocityEngine();
            ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
            ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
            ve.init();
 
            Template t = ve.getTemplate( templateName );
            t.merge( vcontext, writer );
            System.out.println("================");
            System.out.println(writer.toString());
            System.out.println("================");
            return writer.toString();
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

        context.put(entry.getKey(), entry.getValue());
      }
      StringWriter writer = new StringWriter();
     
   
      VelocityEngine ve = new VelocityEngine();
      ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
      ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
      ve.init();
      Template t = ve.getTemplate( "templates/default.vm" );
      t.merge( context, writer );
      System.out.println(writer);
  }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

        //prop.put("directive.parse.max.depth", 10);
        prop.put(RuntimeConstants.OUTPUT_ENCODING, "UTF-8");
        //******************   da passare nelle conf
        prop.put(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, m.get("path"));
        prop.put(RuntimeConstants.PARSER_POOL_SIZE, "40");
        this.ve = new VelocityEngine();

        try {
            this.ve.init(prop);
        } catch (Exception ex) {
        }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

     * @return Velocity engine initialized to read the template directory.
     */
    private VelocityEngine getEngine(String templateDir) {
        if (!this.engines.containsKey(templateDir)) {
            try {
                VelocityEngine engine = new VelocityEngine();
                engine.setProperty("resource.loader", "file");
                engine.setProperty("file.resource.loader.class", GaeVelocityResourceLoader.class.getCanonicalName());
                engine.setProperty("file.resource.loader.path", templateDir);
                engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.Log4JLogChute");
                engine.setProperty("runtime.log.logsystem.log4j.logger", LOGGER.getName());
                engine.setProperty("runtime.references.strict", "true");
                engine.init();
                this.engines.put(templateDir, engine);
            } catch (Exception e) {
                throw new CedarRuntimeException("Failed to initialize Velocity engine: " + e.getMessage(), e);
            }
        }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

     * @param configuration the class configurations.
     * @see org.apache.avalon.framework.configuration.Configurable#configure
     */
    public void configure(Configuration configuration) throws ConfigurationException {
        this.resolverContext = new DefaultContext();
        this.tmplEngine = new VelocityEngine();

        // Set up a JavaScript introspector for the Cocoon flow layer
        this.tmplEngine.setProperty(org.apache.velocity.runtime.RuntimeConstants.UBERSPECT_CLASSNAME,
                                    JSIntrospector.class.getName());
        this.tmplEngine.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this);
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

     * @see org.apache.avalon.framework.configuration.Configurable#configure
     */
    public void configure(Configuration configuration) throws ConfigurationException {
        this.resolverContext = new DefaultContext();
        this.objectExports = new ArrayList();
        this.tmplEngine = new VelocityEngine();
        this.tmplEngine.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this);

        // First set up our default 'cocoon' resource loader
        this.tmplEngine.setProperty("cocoon.resource.loader.class",
                                    TemplateLoader.class.getName());
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

  }

  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

Examples of org.apache.velocity.app.VelocityEngine

    }

    protected void renderContent(Writer out) throws Exception
    {
        VelocityView view = getVelocityView();
        VelocityEngine engine = view.getVelocityEngine();

        if (getTemplate() != null)
        {
            ViewToolContext context = getViewToolContext();
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

        return out.toString();
    }

    protected void renderBody(Writer out) throws Exception
    {
        VelocityEngine engine = getVelocityView().getVelocityEngine();

        /*
         * Eventually, it'd be nice to utilize some AST caching here.
         * But that will likely need to wait until the StringResourceLoader
         * is ready for general use (Velocity 1.6), unless we want to
         * duplicate that minimally here in Tools 2.0
         */
        engine.evaluate(getViewToolContext(), out, getId(),
                        getBodyContent().getReader());
    }
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.