Interface AtmosphereResponse

All Superinterfaces:
javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse
All Known Implementing Classes:
AtmosphereResponseImpl

public interface AtmosphereResponse extends javax.servlet.http.HttpServletResponse
An Atmosphere's response representation. An AtmosphereResponse can be used to construct a bi-directional asynchronous application. If the underlying transport is a WebSocket or if its associated AtmosphereResource has been suspended, this object can be used to write message back to the client at any moment.
This object can delegate the write operation to AsyncIOWriter.
Author:
Jeanfrancois Arcand
  • Method Details

    • destroy

      void destroy()
    • destroy

      void destroy(boolean force)
    • destroyed

      boolean destroyed()
    • addCookie

      void addCookie(javax.servlet.http.Cookie cookie)
      Specified by:
      addCookie in interface javax.servlet.http.HttpServletResponse
    • containsHeader

      boolean containsHeader(String name)
      Specified by:
      containsHeader in interface javax.servlet.http.HttpServletResponse
    • encodeURL

      String encodeURL(String url)
      Specified by:
      encodeURL in interface javax.servlet.http.HttpServletResponse
    • encodeRedirectURL

      String encodeRedirectURL(String url)
      Specified by:
      encodeRedirectURL in interface javax.servlet.http.HttpServletResponse
    • encodeUrl

      String encodeUrl(String url)
      Specified by:
      encodeUrl in interface javax.servlet.http.HttpServletResponse
    • encodeRedirectUrl

      String encodeRedirectUrl(String url)
      Specified by:
      encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse
    • delegateToNativeResponse

      AtmosphereResponse delegateToNativeResponse(boolean delegateToNativeResponse)
    • sendError

      void sendError(int sc, String msg) throws IOException
      Specified by:
      sendError in interface javax.servlet.http.HttpServletResponse
      Throws:
      IOException
    • sendError

      void sendError(int sc) throws IOException
      Specified by:
      sendError in interface javax.servlet.http.HttpServletResponse
      Throws:
      IOException
    • sendRedirect

      void sendRedirect(String location) throws IOException
      Specified by:
      sendRedirect in interface javax.servlet.http.HttpServletResponse
      Throws:
      IOException
    • setDateHeader

      void setDateHeader(String name, long date)
      Specified by:
      setDateHeader in interface javax.servlet.http.HttpServletResponse
    • addDateHeader

      void addDateHeader(String name, long date)
      Specified by:
      addDateHeader in interface javax.servlet.http.HttpServletResponse
    • setHeader

      void setHeader(String name, String value)
      Specified by:
      setHeader in interface javax.servlet.http.HttpServletResponse
    • addHeader

      void addHeader(String name, String value)
      Specified by:
      addHeader in interface javax.servlet.http.HttpServletResponse
    • setIntHeader

      void setIntHeader(String name, int value)
      Specified by:
      setIntHeader in interface javax.servlet.http.HttpServletResponse
    • addIntHeader

      void addIntHeader(String name, int value)
      Specified by:
      addIntHeader in interface javax.servlet.http.HttpServletResponse
    • setStatus

      void setStatus(int status)
      Specified by:
      setStatus in interface javax.servlet.http.HttpServletResponse
    • setStatus

      void setStatus(int status, String statusMessage)
      Specified by:
      setStatus in interface javax.servlet.http.HttpServletResponse
    • getStatus

      int getStatus()
      Specified by:
      getStatus in interface javax.servlet.http.HttpServletResponse
    • getResponse

      javax.servlet.ServletResponse getResponse()
    • getStatusMessage

      String getStatusMessage()
    • headers

      Map<String,String> headers()
    • getHeader

      String getHeader(String name)
      Specified by:
      getHeader in interface javax.servlet.http.HttpServletResponse
    • getHeaders

      Collection<String> getHeaders(String name)
      Specified by:
      getHeaders in interface javax.servlet.http.HttpServletResponse
    • getHeaderNames

      Collection<String> getHeaderNames()
      Specified by:
      getHeaderNames in interface javax.servlet.http.HttpServletResponse
    • setCharacterEncoding

      void setCharacterEncoding(String charSet)
      Specified by:
      setCharacterEncoding in interface javax.servlet.ServletResponse
    • flushBuffer

      void flushBuffer() throws IOException
      Specified by:
      flushBuffer in interface javax.servlet.ServletResponse
      Throws:
      IOException
    • getBufferSize

      int getBufferSize()
      Specified by:
      getBufferSize in interface javax.servlet.ServletResponse
    • getCharacterEncoding

      String getCharacterEncoding()
      Specified by:
      getCharacterEncoding in interface javax.servlet.ServletResponse
    • isDestroyable

      boolean isDestroyable()
      Check if this object can be destroyed. Default is true.
    • destroyable

      AtmosphereResponse destroyable(boolean destroyable)
    • getOutputStream

      javax.servlet.ServletOutputStream getOutputStream() throws IOException
      Specified by:
      getOutputStream in interface javax.servlet.ServletResponse
      Throws:
      IOException
    • getWriter

      PrintWriter getWriter() throws IOException
      Specified by:
      getWriter in interface javax.servlet.ServletResponse
      Throws:
      IOException
    • setContentLength

      void setContentLength(int len)
      Specified by:
      setContentLength in interface javax.servlet.ServletResponse
    • setContentType

      void setContentType(String contentType)
      Specified by:
      setContentType in interface javax.servlet.ServletResponse
    • getContentType

      String getContentType()
      Specified by:
      getContentType in interface javax.servlet.ServletResponse
    • isCommitted

      boolean isCommitted()
      Specified by:
      isCommitted in interface javax.servlet.ServletResponse
    • reset

      void reset()
      Specified by:
      reset in interface javax.servlet.ServletResponse
    • resetBuffer

      void resetBuffer()
      Specified by:
      resetBuffer in interface javax.servlet.ServletResponse
    • setBufferSize

      void setBufferSize(int size)
      Specified by:
      setBufferSize in interface javax.servlet.ServletResponse
    • setLocale

      void setLocale(Locale locale)
      Specified by:
      setLocale in interface javax.servlet.ServletResponse
    • getLocale

      Locale getLocale()
      Specified by:
      getLocale in interface javax.servlet.ServletResponse
    • getAsyncIOWriter

      AsyncIOWriter getAsyncIOWriter()
      Return the underlying AsyncIOWriter.
    • asyncIOWriter

      AtmosphereResponse asyncIOWriter(AsyncIOWriter asyncIOWriter)
      Set an implementation of AsyncIOWriter that will be invoked every time a write operation is ready to be processed.
      Parameters:
      asyncIOWriter - of AsyncIOWriter
      Returns:
      this
    • request

      Return the associated AtmosphereRequest.
      Returns:
      the associated AtmosphereRequest
    • request

      AtmosphereResponse request(AtmosphereRequest atmosphereRequest)
      Set the associated AtmosphereRequest.
      Parameters:
      atmosphereRequest - a AtmosphereRequest
      Returns:
      this
    • close

      void close() throws IOException
      Close the associated AsyncIOWriter.
      Throws:
      IOException
    • closeStreamOrWriter

      void closeStreamOrWriter()
      Close the associated PrintWriter or OutputStream
    • write

      Write the String by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM
      Parameters:
      data - the String to write
    • write

      AtmosphereResponse write(String data, boolean writeUsingOriginalResponse)
      Write the String by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the defined AsyncIOWriter.
      Parameters:
      data - the String to write
      writeUsingOriginalResponse - if true, execute the write without invoking the AsyncIOWriter
    • write

      AtmosphereResponse write(byte[] data)
      Write the bytes by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM.
      Parameters:
      data - the bytes to write
    • write

      AtmosphereResponse write(byte[] data, boolean writeUsingOriginalResponse)
      Write the String by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the defined AsyncIOWriter.
      Parameters:
      data - the bytes to write
      writeUsingOriginalResponse - if true, execute the write without invoking the AsyncIOWriter
    • write

      AtmosphereResponse write(byte[] data, int offset, int length)
      Write the bytes by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM.
      Parameters:
      data - the bytes to write
      offset - the first byte position to write
      length - the data length
    • write

      AtmosphereResponse write(byte[] data, int offset, int length, boolean writeUsingOriginalResponse)
      Write the String by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the defined AsyncIOWriter.
      Parameters:
      data - the bytes to write
      offset - the first byte position to write
      length - the data length
      writeUsingOriginalResponse - if true, execute the write without invoking the AsyncIOWriter
    • resource

      AtmosphereResource resource()
      The AtmosphereResource associated with this request. If the request hasn't been suspended, this method will return null.
      Returns:
      an AtmosphereResource, or null.
    • setResponse

      void setResponse(javax.servlet.ServletResponse response)
    • uuid

      String uuid()
      Return the AtmosphereResource.uuid() used by this object.
      Returns:
      the AtmosphereResource.uuid() used by this object.
    • toString

      String toString()
      Overrides:
      toString in class Object