use of org.apache.velocity.Template in project gocd by gocd.
the class TestVelocityView method setupTemplate.
private Template setupTemplate(ResourceLoader loader, RuntimeInstance runtimeServices, String templateName, InputStream templateContents) {
try {
Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setResourceLoader(loader);
template.setName(templateName);
byte[] bytes = IOUtils.toByteArray(templateContents);
templateContents.close();
when(loader.getResourceStream(templateName)).thenReturn(new ByteArrayInputStream(bytes));
doReturn(template).when(runtimeServices).getTemplate(templateName);
doReturn(template).when(runtimeServices).getTemplate(eq(templateName), Matchers.<String>any());
return template;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.velocity.Template in project cxf by apache.
the class VelocityGenerator method doWrite.
public void doWrite(String templateName, Writer outputs) throws ToolException {
Template tmpl = null;
try {
tmpl = Velocity.getTemplate(templateName);
} catch (Exception e) {
Message msg = new Message("TEMPLATE_MISSING", LOG, templateName);
throw new ToolException(msg, e);
}
VelocityContext ctx = new VelocityContext();
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
ctx.put(entry.getKey(), entry.getValue());
}
VelocityWriter writer = new VelocityWriter(outputs);
ctx.put("out", writer);
try {
tmpl.merge(ctx, writer);
writer.close();
} catch (Exception e) {
Message msg = new Message("VELOCITY_ENGINE_WRITE_ERRORS", LOG);
throw new ToolException(msg, e);
}
}
use of org.apache.velocity.Template in project winery by eclipse.
the class BpelPlanArtefactWriter method completeInvokerXsdTemplate.
public String completeInvokerXsdTemplate() {
LOGGER.debug("Retrieving service invoker XSD");
VelocityContext context = new VelocityContext();
Template invokerXsdTemplate = Velocity.getTemplate(TEMPLATE_PATH + "invoker.xsd");
StringWriter xsdWriter = new StringWriter();
invokerXsdTemplate.merge(context, xsdWriter);
return xsdWriter.toString();
}
use of org.apache.velocity.Template in project winery by eclipse.
the class BpelPlanArtefactWriter method completeInvokerWsdlTemplate.
public String completeInvokerWsdlTemplate() {
LOGGER.debug("Retrieving service invoker WSDL");
VelocityContext context = new VelocityContext();
Template invokerWsdlTemplate = Velocity.getTemplate(TEMPLATE_PATH + "invoker.wsdl");
StringWriter wsdlWriter = new StringWriter();
invokerWsdlTemplate.merge(context, wsdlWriter);
return wsdlWriter.toString();
}
use of org.apache.velocity.Template in project winery by eclipse.
the class BpelPlanArtefactWriter method completeDeploymentDescriptorTemplate.
public String completeDeploymentDescriptorTemplate() {
LOGGER.debug("Retrieving Apache ODE deployment descriptor");
VelocityContext context = new VelocityContext();
Template invokerXsdTemplate = Velocity.getTemplate(TEMPLATE_PATH + "deploy.xml");
StringWriter xsdWriter = new StringWriter();
invokerXsdTemplate.merge(context, xsdWriter);
return xsdWriter.toString();
}
Aggregations