Package org.apache.velocity.app

Examples of org.apache.velocity.app.VelocityEngine


            throw new IllegalArgumentException(gripe);
        }

        Properties p = loadConfiguration(context);

        VelocityEngine velocityEngine = new VelocityEngine();

        //  Set the velocity attribute for the servlet context
        //  if this is not set the webapp loader WILL NOT WORK
        velocityEngine.setApplicationAttribute(ServletContext.class.getName(),
                context);

        try {
            velocityEngine.init(p);
        } catch (Exception e) {
            throw new StrutsException("Unable to instantiate VelocityEngine!", e);
        }

        return velocityEngine;
View Full Code Here


        HttpServletRequest req = (HttpServletRequest) actionContext.get(ServletActionContext.HTTP_REQUEST);
        HttpServletResponse res = (HttpServletResponse) actionContext.get(ServletActionContext.HTTP_RESPONSE);

        // prepare velocity
        velocityManager.init(servletContext);
        VelocityEngine velocityEngine = velocityManager.getVelocityEngine();

        // get the list of templates we can use
        List<Template> templates = templateContext.getTemplate().getPossibleTemplates(this);

        // find the right template
        org.apache.velocity.Template template = null;
        String templateName = null;
        Exception exception = null;
        for (Template t : templates) {
            templateName = getFinalTemplateName(t);
            try {
                // try to load, and if it works, stop at the first one
                template = velocityEngine.getTemplate(templateName);
                break;
            } catch (IOException e) {
                if (exception == null) {
                    exception = e;
                }
View Full Code Here

     * @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

        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

            log.info("   Control file       ["+mainPage+"]");
            log.info("   Template directory ["+templateDir+"]");
            log.info("   Output directory   ["+outputDir+"]");

            // Fire up Velocity engine, point it at templates and init
            VelocityEngine engine = new VelocityEngine();
            engine.setProperty("resource.loader","file");
            engine.setProperty("file.resource.loader.class",
              "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
            engine.setProperty("file.resource.loader.path", templateDir);
            engine.init();
           
            // Build context with current date
            VelocityContext context = new VelocityContext();
            context.put("date", new Date());
            // TODO fix: Use one utilities model and not one of the below
View Full Code Here

    private VelocityEngine ve;
    private boolean loadFromClassPath;

    private void init() {
        if (ve == null) {
            ve = new VelocityEngine();
            try {
                String root = getContainer().getProperty("webapp.dir");
                ve.setProperty("runtime.log", root + "/velocity.log");
                if (loadFromClassPath) {
                    ve.setProperty("resource.loader", "class");
View Full Code Here

      ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
      FirewallManager firewallManager = new FirewallManager(
          computeServiceContext, clusterSpec, newCluster);

      VelocityEngine velocityEngine = TemplateUtils.newVelocityEngine();

      ClusterActionEvent event = new ClusterActionEvent(getAction(), clusterSpec,
          instanceTemplate, newCluster, statementBuilder, getCompute(), firewallManager, velocityEngine);

      eventMap.put(instanceTemplate, event);
View Full Code Here

    public void testGenerate() throws Exception {
        Properties props = new Properties();
        InputStream propsStream = getClass().getResourceAsStream("/org/apache/tiles/autotag/velocity.properties");
        props.load(propsStream);
        propsStream.close();
        VelocityEngine velocityEngine = new VelocityEngine(props);

        FMModelRepositoryGenerator generator = new FMModelRepositoryGenerator(velocityEngine);
        File file = File.createTempFile("autotag", null);
        file.delete();
        file.mkdir();
View Full Code Here

    public void testGenerate() throws Exception {
        Properties props = new Properties();
        InputStream propsStream = getClass().getResourceAsStream("/org/apache/tiles/autotag/velocity.properties");
        props.load(propsStream);
        propsStream.close();
        VelocityEngine velocityEngine = new VelocityEngine(props);

        FMModelGenerator generator = new FMModelGenerator(velocityEngine);
        File file = File.createTempFile("autotag", null);
        file.delete();
        file.mkdir();
View Full Code Here

    public void testGenerate() throws Exception {
        Properties props = new Properties();
        InputStream propsStream = getClass().getResourceAsStream("/org/apache/tiles/autotag/velocity.properties");
        props.load(propsStream);
        propsStream.close();
        VelocityEngine velocityEngine = new VelocityEngine(props);

        TLDGenerator generator = new TLDGenerator(velocityEngine);
        File file = File.createTempFile("autotag", null);
        file.delete();
        file.mkdir();
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.