Interface TemplateProcessor<T>
-
- Type Parameters:
T- the type of the template object.
- All Known Implementing Classes:
AbstractTemplateProcessor
@Contract @ConstrainedTo(SERVER) public interface TemplateProcessor<T>
A view processor. Implementations of this interface shall be capable of resolving a template name (+ media type) to a template reference that identifies a template supported by the implementation. And, processing the template, identified by template reference and media type, the results of which are written to an output stream. Implementations can register a view processor as a provider, for example, annotating the implementation class withProvideror registering an implementing class or instance as a singleton withResourceConfigorApplication. Such view processors could be JSP view processors (supported by the Jersey servlet and filter implementations) or say Freemarker or Velocity view processors (not implemented).- Author:
- Paul Sandoz, Michal Gajdos
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Tresolve(String name, MediaType mediaType)Resolve a template name to a template reference.voidwriteTo(T templateReference, Viewable viewable, MediaType mediaType, MultivaluedMap<String,Object> httpHeaders, OutputStream out)Process a template and write the result to an output stream.
-
-
-
Method Detail
-
resolve
T resolve(String name, MediaType mediaType)
Resolve a template name to a template reference.- Parameters:
name- the template name.mediaType- requested media type of the template.- Returns:
- the template reference, otherwise
nullif the template name cannot be resolved.
-
writeTo
void writeTo(T templateReference, Viewable viewable, MediaType mediaType, MultivaluedMap<String,Object> httpHeaders, OutputStream out) throws IOException
Process a template and write the result to an output stream.- Parameters:
templateReference- the template reference. This is obtained by calling theresolve(String, jakarta.ws.rs.core.MediaType)method with a template name and media type.viewable- the viewable that contains the model to be passed to the template.mediaType- media type thetemplateReferenceshould be transformed into.httpHeaders- http headers that will be send in the response. Headers can be modified to influence response headers before the the first byte is written to theout. After the response buffer is committed the headers modification has no effect. Template processor can for example set the content type of the response.out- the output stream to write the result of processing the template.- Throws:
IOException- if there was an error processing the template.- Since:
- 2.7
-
-