public void renderPageResponse(Page page) throws IOException {
Defense.notNull(page, "page");
ContentType contentType = pageContentTypeAnalyzer.findContentType(page);
// For the moment, the content type is all that's used determine the model for the markup writer.
// It's something of a can of worms.
MarkupWriter writer = markupWriterFactory.newMarkupWriter(contentType);
markupRenderer.renderPageMarkup(page, writer);
PrintWriter pw = response.getPrintWriter(contentType.toString());
long startNanos = System.nanoTime();
writer.toMarkup(pw);
long endNanos = System.nanoTime();
if (logger.isDebugEnabled())
{
long elapsedNanos = endNanos - startNanos;
double elapsedSeconds = ((float) elapsedNanos) / 1000000000F;
logger.debug(String.format("Response DOM streamed to markup in %.3f seconds",
elapsedSeconds));
}
pw.flush();
}
|