users@jersey.java.net

*BREAKING CHANGES* <was> Re: [Jersey] Deprecated TemplateProcessor. Use ViewProcessor.

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 30 Dec 2009 12:00:17 +0100

I forgot to add the following:

*BREAKING CHANGES* for com.sun.jersey.spi.template.TemplateContext and
com.sun.jersey.spi.template.ResolvedViewable.

TemplateContext no longer has a method to obtain the set of
TemplateProcessor.

The constructors of ResolvedViewable were modified to be compatible
with ViewProcessor.

I suspect the above changes are unlikely to affect anybody as
developers are using Viewable and maybe to a lesser extent (?)
TemplateContext to resolve a Viewable to a ResolvedViewable. FWIW such
changes did not break related Jersey code.

Paul.

On Dec 30, 2009, at 11:52 AM, Paul Sandoz wrote:

> 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;
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>