Class ServiceResponse<T>

Type Parameters:
T - generic type
Direct Known Subclasses:
BsonResponse, ByteArrayResponse, JsonResponse, StringResponse

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 <[email protected]>
  • Field Details

    • content

      protected T content
  • Constructor Details

    • ServiceResponse

      protected ServiceResponse(io.undertow.server.HttpServerExchange exchange)
  • Method Details

    • 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
    • setCustomerSender

      public void setCustomerSender(Runnable customSender)
      If a customSender is set (not null), the handler ResponseSender will delegate to customSender.run() the responsability to send the response content to the client
      Parameters:
      customSender -
    • getCustomerSender

      public Runnable getCustomerSender()
      SeesetCustomerSender()
      Returns:
      the customSender
    • setInError

      public abstract void setInError(int code, String message, Throwable t)
      Specified by:
      setInError in class Response<T>
      Parameters:
      code -
      message -
      t -