use of groovy.xml.MarkupBuilder in project ratpack by ratpack.
the class Markup method render.
@Override
public void render(Context context) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out, CharsetUtil.encoder(getEncoding()));
MarkupBuilder markupBuilder = new MarkupBuilder(writer);
ClosureUtil.configureDelegateFirst(markupBuilder, markupBuilder, getDefinition());
context.getResponse().contentType(getContentType()).send(out.toByteArray());
}
use of groovy.xml.MarkupBuilder in project service-proxy by membrane.
the class WebServiceExplorerInterceptor method generateSampleRequest.
private String generateSampleRequest(final String portName, final String operationName, final String bindingName, final Definitions w) {
StringWriter writer = new StringWriter();
SOARequestCreator creator = new SOARequestCreator(w, new RequestTemplateCreator(), new MarkupBuilder(writer));
creator.createRequest(portName, operationName, bindingName);
return writer.toString();
}
use of groovy.xml.MarkupBuilder in project groovy by apache.
the class ServletBinding method lazyInit.
private void lazyInit() {
if (initialized)
return;
initialized = true;
HttpServletResponse response = (HttpServletResponse) super.getVariable("response");
ServletOutput output = new ServletOutput(response);
super.setVariable("out", output.getWriter());
super.setVariable("sout", output.getOutputStream());
MarkupBuilder builder = new MarkupBuilder(output.getWriter());
builder.setExpandEmptyElements(true);
super.setVariable("html", builder);
try {
// load using reflection to avoid needing a hard requirement on groovy-json for those not needing JSON support
Class jsonBuilderClass = this.getClass().getClassLoader().loadClass("groovy.json.StreamingJsonBuilder");
Constructor writerConstructor = getWriterConstructor(jsonBuilderClass);
super.setVariable("json", writerConstructor.newInstance(output.getWriter()));
} catch (Throwable t) {
t.printStackTrace();
}
// bind forward method
MethodClosure c = new MethodClosure(this, "forward");
super.setVariable("forward", c);
// bind include method
c = new MethodClosure(this, "include");
super.setVariable("include", c);
// bind redirect method
c = new MethodClosure(this, "redirect");
super.setVariable("redirect", c);
}
use of groovy.xml.MarkupBuilder in project gradle by gradle.
the class TestNGOptions method suiteXmlBuilder.
public MarkupBuilder suiteXmlBuilder() {
suiteXmlWriter = new StringWriter();
suiteXmlBuilder = new MarkupBuilder(suiteXmlWriter);
return suiteXmlBuilder;
}
use of groovy.xml.MarkupBuilder in project irontest by zheng-wang.
the class WSDLResource method getOperationInfo.
@GET
@Path("/{wsdlUrl}/bindings/{bindingName}/operations/{operationName}")
public SOAPOperationInfo getOperationInfo(@PathParam("wsdlUrl") String wsdlUrl, @PathParam("bindingName") String bindingName, @PathParam("operationName") String operationName) {
SOAPOperationInfo info = new SOAPOperationInfo();
WSDLParser parser = new WSDLParser();
Definitions definition = parser.parse(wsdlUrl);
StringWriter writer = new StringWriter();
SOARequestCreator creator = new SOARequestCreator(definition, new RequestTemplateCreator(), new MarkupBuilder(writer));
creator.createRequest(null, operationName, bindingName);
info.setSampleRequest(writer.toString());
return info;
}
Aggregations