protected final Response fillTemplate(Closure<StringTemplate> populator) {
   StringWriter output = new StringWriter();
   try {
     templateHelper.writeTemplate(output, populator);
   } catch (TemplateException e) {
     throw new WebApplicationException(e);
   }
   return Response.ok(output.toString()).build();
 }
Пример #2
0
 private String fillTemplate(final Iterable<DisplayMetric> metrics) {
   StringWriter output = new StringWriter();
   try {
     templateHelper.writeTemplate(
         output,
         new Closure<StringTemplate>() {
           @Override
           public void execute(StringTemplate template) {
             template.setAttribute("cluster_name", clusterName);
             template.setAttribute("metrics", metrics);
           }
         });
   } catch (TemplateException e) {
     throw new WebApplicationException(e);
   }
   return output.toString();
 }