Package com.yahoo.processing.rendering
Class Renderer<RESPONSE extends Response>
java.lang.Object
com.yahoo.component.AbstractComponent
com.yahoo.processing.rendering.Renderer<RESPONSE>
- All Implemented Interfaces:
com.yahoo.component.Component
,com.yahoo.component.Deconstructable
,Cloneable
,Comparable<com.yahoo.component.Component>
- Direct Known Subclasses:
AsynchronousRenderer
public abstract class Renderer<RESPONSE extends Response>
extends com.yahoo.component.AbstractComponent
implements Cloneable
Renders a response to a stream. The renderers are cloned just before
rendering, and must therefore obey the following contract:
- At construction time, only final members shall be initialized, and these must refer to immutable data only.
- State mutated during rendering shall be initialized in the init method.
- Author:
- Tony Vaagenes, Steinar Knutsen
-
Field Summary
Fields inherited from class com.yahoo.component.AbstractComponent
isDeconstructable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Used to create a separate instance for each result to render.abstract String
Name of the output encoding, if applicable.abstract String
The MIME type of the rendered content sent to the client.void
init()
Initializes the mutable state, see the contract in the class documentation.com.google.common.util.concurrent.ListenableFuture<Boolean>
render
(OutputStream stream, RESPONSE response, Execution execution, Request request) Deprecated, for removal: This API element is subject to removal in a future version.renderResponse
(OutputStream stream, RESPONSE response, Execution execution, Request request) Render a response to a stream.Methods inherited from class com.yahoo.component.AbstractComponent
compareTo, deconstruct, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable, toString
-
Constructor Details
-
Renderer
public Renderer()
-
-
Method Details
-
clone
Used to create a separate instance for each result to render.- Overrides:
clone
in classcom.yahoo.component.AbstractComponent
-
init
public void init()Initializes the mutable state, see the contract in the class documentation. Called on the clone just before rendering. -
render
@Deprecated(forRemoval=true, since="7") public com.google.common.util.concurrent.ListenableFuture<Boolean> render(OutputStream stream, RESPONSE response, Execution execution, Request request) Deprecated, for removal: This API element is subject to removal in a future version.Use/implementrenderResponse(OutputStream, Response, Execution, Request)
instead. Return type changed fromListenableFuture
toCompletableFuture
. -
renderResponse
public CompletableFuture<Boolean> renderResponse(OutputStream stream, RESPONSE response, Execution execution, Request request) Render a response to a stream. The stream also exposes a ByteBuffer API for efficient transactions to JDisc. The returned future will throw the exception causing failure wrapped in an ExecutionException if rendering was not successful.- Parameters:
stream
- a stream API bridge to JDiscresponse
- the response to renderexecution
- the execution which created this responserequest
- the request matching the response- Returns:
- a
CompletableFuture
containing a boolean where true indicates a successful rendering
-
getEncoding
Name of the output encoding, if applicable.- Returns:
- the encoding of the output if applicable, e.g. "utf-8"
-
getMimeType
The MIME type of the rendered content sent to the client.- Returns:
- The mime type of the data written to the writer, e.g. "text/plain"
-
renderResponse(OutputStream, Response, Execution, Request)
instead.