Examples of VelocityEngine


Examples of org.apache.flex.forks.velocity.app.VelocityEngine

  /**
   * Create a VelocityEngine instance configured with the given libs string
   */
  private static final VelocityEngine createEngine(String lib)
  {
    VelocityEngine ve = new VelocityEngine();
    // use our logger, and customize log settings
    ve.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, LOGSYSTEM_CLASS);
    ve.setProperty(Velocity.RUNTIME_LOG_ERROR_STACKTRACE, "false");
    ve.setProperty(Velocity.RUNTIME_LOG_REFERENCE_LOG_INVALID, "true");
    // use our strict introspection
    ve.setProperty(Velocity.UBERSPECT_CLASSNAME, STRICT_UBERSPECT_IMPL_CLASS);
    // load from classpath and file system
    ve.setProperty(Velocity.RESOURCE_LOADER, "file,class");
    // configure class resource loader
    ve.setProperty("class." + Velocity.RESOURCE_LOADER + ".class", CLASSPATH_RESOURCE_LOADER_CLASS);

    // libs are precompiled in later in this function
    ve.setProperty(Velocity.VM_LIBRARY, "");
    // initialize

    try
    {
      ve.init();
    }
    catch (Exception e)
    {
      ThreadLocalToolkit.log(new InitializationError(e.getLocalizedMessage()));
    }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

                htmlPage.writeHead(OutputConverter.getWriter(buffer));
                context.put("head", buffer.toString());
            }

            //Rendering the content
            VelocityEngine velocityEngine = VelocityManager.getInstance().getVelocityEngine();

            Template template = velocityEngine.getTemplate(decorator.getPage());
            StringWriter tempWriter = new StringWriter();
            template.merge(context, tempWriter);
            String renderResult = tempWriter.toString();

            response.getWriter().print(renderResult);
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

        template.merge(context, tempWriter);
        return tempWriter.toString();
    }

    public static Template getTemplate(String templateName) throws Exception {
        VelocityEngine velocityEngine = VelocityManager.getInstance().getVelocityEngine();

        /*
         * if (velocityEngine == null) { velocityEngine = new VelocityEngine();
         * Properties props = new Properties();
         * props.load(ClassLoaderUtils.getResourceAsStream("test-velocity.properties",
         * com.opensymphony.webwork.portlet.sitemesh.VelocityUtils.class));
         * props.list(System.out); velocityEngine.init(props); }
         */
        String encoding = "UTF-8";

        Template template = velocityEngine.getTemplate(templateName, encoding);
        return template;
    }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

            throw new IllegalArgumentException(gripe);
        }

        Properties p = loadConfiguration(context);

        VelocityEngine velocityEngine = new VelocityEngine();

        try {
            velocityEngine.init(p);
        } catch (Exception e) {
            String gripe = "Unable to instantiate VelocityEngine!";
            log.error(gripe, e);
            throw new RuntimeException(gripe);
        }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

    public void testDirectVelocity()
        throws Exception
    {
        StringWriter writer = new StringWriter();

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

        VelocityContext velocityContext = new VelocityContext();

        velocityContext.put("test1", "@test1@");
        velocityContext.put("test2", "@test2@");

        assertTrue(engine.evaluate(velocityContext, writer, "mylogtag", "$test1$test2"));
        assertEquals(
            "@test1@@test2@",
            writer.getBuffer().toString());
    }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

    {
        super.init( serviceConfig );

        try
        {
            _engine = new VelocityEngine(  );
            _engine.init( getProperties( serviceConfig.getServletConfig(  ) ) );
        }
        catch ( Exception e )
        {
            throw new PortletServiceException( e );
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

            engineProperties.addProperty(
                VelocityEngine.VM_LIBRARY,
                iterator.next());
        }

        this.velocityEngine = new VelocityEngine();
        this.velocityEngine.setExtendedProperties(engineProperties);

        if (this.mergeLocation != null)
        {
            // set the file resource path (to the merge location)
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

      }

      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

Examples of org.apache.velocity.app.VelocityEngine

  private MailerWithTemplate() {
    super();
    // init velocity engine
    Properties p = null;
    try {
      velocityEngine = new VelocityEngine();
      p = new Properties();
      // p.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
      // "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
      // p.setProperty(RuntimeConstants.RUNTIME_LOG,
      // OLATContext.getUserdataRoot() + "logs/velocity-email.log.txt");
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

  public UserBulkChangeManager() {
    // init velocity engine
    Properties p = null;
    try {
      velocityEngine = new VelocityEngine();
      p = new Properties();
      velocityEngine.init(p);
    } catch (Exception e) {
      throw new RuntimeException("config error " + p.toString());
    }
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.