Package org.apache.velocity

Examples of org.apache.velocity.Template.merge()


      }

      Writer writer = new OutputStreamWriter(response.getOutputStream(),
          encoding);
      // Render the layout template into the response
      t.merge(context, writer);

      // generator exec template time
      Date cur_time = Calendar.getInstance(
          invocation.getInvocationContext().getLocale()).getTime();
      writer.write("\r\n<!-- Generated by EATELE.NET (");
View Full Code Here


            Template t = this.ve.getTemplate(template);
            VelocityContext context = new VelocityContext();
            context.put("data", m);
            StringWriter writer = new StringWriter();
            t.merge(context, writer);
            return writer.toString();

        } catch (ResourceNotFoundException ex) {
            return ex.getMessage();
        } catch (ParseErrorException ex) {
View Full Code Here

      template = this.velocityEngine.getTemplate(templateName);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    StringWriter writer = new StringWriter();
    template.merge(context, writer);
    return writer.toString();
  }

  OutputFile compileInterface(Protocol protocol) {
    protocol = addStringType(protocol);           // annotate protocol as needed
View Full Code Here

            {
                context.put(getBodyContentKey(), getRenderedBody());
            }

            // render the template into the writer
            template.merge(context, out);
        }
        else
        {
            // render the body into the writer
            renderBody(out);
View Full Code Here

        Template template = Velocity.getTemplate("/org/apache/tomee/configs/" + filename);
        VelocityContext context = new VelocityContext();
        context.put("tomcatHttpPort", Integer.toString(configuration.getHttpPort()));
        context.put("tomcatShutdownPort", Integer.toString(configuration.getStopPort()));
        Writer writer = new FileWriter(new File(targetDir, filename));
        template.merge(context, writer);
        writer.flush();
        writer.close();
    }

    private void copyFileTo(File targetDir, String filename) throws IOException {
View Full Code Here

            FileReader templateReader = null;
            try {
                out = new PrintStream(new FileOutputStream(outputFile));

                PrintWriter writer = new PrintWriter(out);
                template.merge(context, writer);
                writer.flush();
            } finally {
                close(out);
                close(templateReader);
            }
View Full Code Here

            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();

            LinkedHashSet dependencies = toDependencies();
            org.apache.geronimo.kernel.repository.Artifact configId = new org.apache.geronimo.kernel.repository.Artifact(groupId, artifactId, version, "car");
View Full Code Here

             */
            Template template = Velocity.getTemplate(templateFile);

            Writer writer = new BufferedWriter(new OutputStreamWriter(System.out));
            template.merge( context , writer);

            writer.flush();
            writer.close();
        }
        catch( Exception e )
View Full Code Here

        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();

        XmlObject doc = XmlObject.Factory.parse(plan);
        XmlCursor xmlCursor = doc.newCursor();
View Full Code Here

      ctx.put("clusterMode", clusterMode);
      ctx.put("hadoopVersion", hadoopVersion);

      File outFile = new File(outDir, className + ".java");
      FileWriter writer = new FileWriter(outFile);
      t.merge(ctx, writer);
      writer.close();

      System.out.println("Generated " + outFile.getCanonicalPath() + " from template " + template);
    } catch(BuildException e) {
      throw e;
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.