Package org.restheart.exchange
Class ServiceResponse<T>
- java.lang.Object
-
- org.restheart.exchange.Exchange<T>
-
- org.restheart.exchange.Response<T>
-
- org.restheart.exchange.ServiceResponse<T>
-
- Type Parameters:
T-
- Direct Known Subclasses:
BsonResponse,ByteArrayResponse,JsonResponse
public abstract class ServiceResponse<T> extends Response<T>
Base class for Response implementations that can be used in service requests. Only one response object can be instantiated per request. The response object is instantiated by ServiceExchangeInitializer using the responseInitializer() function defined by the handling service- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
-
Field Summary
Fields Modifier and Type Field Description protected Tcontent-
Fields inherited from class org.restheart.exchange.Exchange
APP_FORM_URLENCODED_TYPE, APPLICATION_PDF_TYPE, HAL_JSON_MEDIA_TYPE, IN_ERROR_KEY, JSON_MEDIA_TYPE, LOGGER, MAX_BUFFERS, MAX_CONTENT_SIZE, MULTIPART_FORM_DATA_TYPE, wrapped
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedServiceResponse(io.undertow.server.HttpServerExchange exchange)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TgetContent()static ServiceResponse<?>of(io.undertow.server.HttpServerExchange exchange)static <R extends ServiceResponse<?>>
Rof(io.undertow.server.HttpServerExchange exchange, Class<R> type)abstract StringreadContent()Reads the content as a String.voidsetContent(T content)abstract voidsetInError(int code, String message, Throwable t)-
Methods inherited from class org.restheart.exchange.Response
getContentType, getContentType, getMDCContext, getStatusCode, setContentType, setContentTypeAsJson, setInError, setMDCContext, setStatusCode, type
-
Methods inherited from class org.restheart.exchange.Exchange
getExchange, getWrappedExchange, isAccountInRole, isAuthenticated, isAuthenticated, isContentTypeJson, isContentTypeText, isContentTypeXml, isInError, isInError, responseInterceptorsExecuted, setInError, setInError, setResponseInterceptorsExecuted, updateBufferSize
-
-
-
-
Field Detail
-
content
protected T content
-
-
Method Detail
-
of
public static ServiceResponse<?> of(io.undertow.server.HttpServerExchange exchange)
-
of
public static <R extends ServiceResponse<?>> R of(io.undertow.server.HttpServerExchange exchange, Class<R> type)
-
getContent
public T getContent()
-
setContent
public void setContent(T content)
-
readContent
public abstract String readContent()
Reads the content as a String. This method is used by ResponseSender to generate the response content to send to the client.- Returns:
- the content as string
-
setInError
public abstract void setInError(int code, String message, Throwable t)- Specified by:
setInErrorin classResponse<T>- Parameters:
code-message-t-
-
-