Hi,
As part of the changes to improve the MVC area of Jersey i have
deprecated TemplateProcessor. Note that existing TemplateProcessor
implementations are still supported.
A new interface is provided called ViewProcessor that enables the
resolving of an absolute template name to a template reference (an
instance of a generic type) which is passed to the writeTo method, in
addition to a Viewable instance that contains the model and a
resolving class (if utilized).
When writing out an view with an absolute template name, or a view
with a resolving class then it is not required that an HTTP request be
in scope, unless the ViewProcessor implementation requires it.
I have updated the JSP support and the Lift template support to use
ViewProcessor, and for the later there is no duplication of template
look up, the method signatures being as follows:
class LiftTemplateProcessor extends ViewProcessor[NodeSeq] {
def resolve(path: String): NodeSeq = { ... }
def writeTo(nodes: NodeSeq, viewable: Viewable, out:
OutputStream): Unit = { ... }
}
Paul.
public interface ViewProcessor<T> {
/**
* Resolve a template name to a template reference.
*
* @param name the template name
* @return the template reference, otherwise null
* if the template name cannot be resolved.
*/
T resolve(String name);
/**
* Process a template and write the result to an output stream.
*
* @param t the template reference. This is obtained by calling the
* {_at_link #resolve(java.lang.String)} method with a
template name.
* @param viewable the viewable that contains the model to be
passed to the
* template.
* @param out the output stream to write the result of processing
the
* template.
* @throws java.io.IOException if there was an error processing the
* template.
*/
void writeTo(T t, Viewable viewable, OutputStream out) throws
IOException;
}