/** Pattern to extract the part of the class name preceding the "Task" postfix */
private static final Pattern CLASS_NAME_PREFIX_PATTERN = Pattern.compile(".*\\.(.+)Task.*");
/** @return the PostAction returned from {@link StRenderer#actionAndRender(ObjectProvider, Map)} on the given task */
private PostAction render(ITask t, Map<String, String[]> reqParams, RequestHandler request, final List<EmbeddedContent> embeddedContent, final String relativeTemplatePath) {
StRenderer renderer = new StRenderer(stringTemplateFactory, t) {
@Override protected Pattern getClassNamePrefixPattern() {
return CLASS_NAME_PREFIX_PATTERN;
}
@Override protected String getPageRelativePath() {
return relativeTemplatePath;
}
@Override protected String renderFinal(StringTemplate st) {
if (embeddedContent != null)
addEmbedded(embeddedContent, st);
return super.renderFinal(st);
}
};
registerInputArgParser(renderer);
ObjectProvider injector = makeObjectProvider(request);
long nt = System.nanoTime();
PostAction po = renderer.actionAndRender(injector, makeLifecycleHandlerSet(request), reqParams);
log.info("StRender of " + t.getClass().getSimpleName() + " in " + TimeUnit.MILLISECONDS.convert(System.nanoTime() - nt, TimeUnit.NANOSECONDS) + " ms");
return po;
}