Package org.atmosphere.cpr
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
This object can delegate the write operation to
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
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface javax.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookie(javax.servlet.http.Cookie cookie) voidaddDateHeader(String name, long date) voidvoidaddIntHeader(String name, int value) asyncIOWriter(AsyncIOWriter asyncIOWriter) Set an implementation ofAsyncIOWriterthat will be invoked every time a write operation is ready to be processed.voidclose()Close the associatedAsyncIOWriter.voidClose the associatedPrintWriterorOutputStreambooleancontainsHeader(String name) delegateToNativeResponse(boolean delegateToNativeResponse) voiddestroy()voiddestroy(boolean force) destroyable(boolean destroyable) booleanencodeRedirectUrl(String url) encodeRedirectURL(String url) voidReturn the underlyingAsyncIOWriter.intgetHeaders(String name) javax.servlet.ServletOutputStreamjavax.servlet.ServletResponseintheaders()booleanbooleanCheck if this object can be destroyed.request()Return the associatedAtmosphereRequest.request(AtmosphereRequest atmosphereRequest) Set the associatedAtmosphereRequest.voidreset()voidresource()TheAtmosphereResourceassociated with this request.voidsendError(int sc) voidvoidsendRedirect(String location) voidsetBufferSize(int size) voidsetCharacterEncoding(String charSet) voidsetContentLength(int len) voidsetContentType(String contentType) voidsetDateHeader(String name, long date) voidvoidsetIntHeader(String name, int value) voidvoidsetResponse(javax.servlet.ServletResponse response) voidsetStatus(int status) voidtoString()uuid()Return theAtmosphereResource.uuid()used by this object.write(byte[] data) Write the bytes by either using thePrintWriterorOutputStream.write(byte[] data, boolean writeUsingOriginalResponse) Write the String by either using thePrintWriterorOutputStream.write(byte[] data, int offset, int length) Write the bytes by either using thePrintWriterorOutputStream.write(byte[] data, int offset, int length, boolean writeUsingOriginalResponse) Write the String by either using thePrintWriterorOutputStream.Write the String by either using thePrintWriterorOutputStream.Write the String by either using thePrintWriterorOutputStream.
-
Method Details
-
destroy
void destroy() -
destroy
void destroy(boolean force) -
destroyed
boolean destroyed() -
addCookie
void addCookie(javax.servlet.http.Cookie cookie) - Specified by:
addCookiein interfacejavax.servlet.http.HttpServletResponse
-
containsHeader
- Specified by:
containsHeaderin interfacejavax.servlet.http.HttpServletResponse
-
encodeURL
- Specified by:
encodeURLin interfacejavax.servlet.http.HttpServletResponse
-
encodeRedirectURL
- Specified by:
encodeRedirectURLin interfacejavax.servlet.http.HttpServletResponse
-
encodeUrl
- Specified by:
encodeUrlin interfacejavax.servlet.http.HttpServletResponse
-
encodeRedirectUrl
- Specified by:
encodeRedirectUrlin interfacejavax.servlet.http.HttpServletResponse
-
delegateToNativeResponse
-
sendError
- Specified by:
sendErrorin interfacejavax.servlet.http.HttpServletResponse- Throws:
IOException
-
sendError
- Specified by:
sendErrorin interfacejavax.servlet.http.HttpServletResponse- Throws:
IOException
-
sendRedirect
- Specified by:
sendRedirectin interfacejavax.servlet.http.HttpServletResponse- Throws:
IOException
-
setDateHeader
- Specified by:
setDateHeaderin interfacejavax.servlet.http.HttpServletResponse
-
addDateHeader
- Specified by:
addDateHeaderin interfacejavax.servlet.http.HttpServletResponse
-
setHeader
- Specified by:
setHeaderin interfacejavax.servlet.http.HttpServletResponse
-
addHeader
- Specified by:
addHeaderin interfacejavax.servlet.http.HttpServletResponse
-
setIntHeader
- Specified by:
setIntHeaderin interfacejavax.servlet.http.HttpServletResponse
-
addIntHeader
- Specified by:
addIntHeaderin interfacejavax.servlet.http.HttpServletResponse
-
setStatus
void setStatus(int status) - Specified by:
setStatusin interfacejavax.servlet.http.HttpServletResponse
-
setStatus
- Specified by:
setStatusin interfacejavax.servlet.http.HttpServletResponse
-
getStatus
int getStatus()- Specified by:
getStatusin interfacejavax.servlet.http.HttpServletResponse
-
getResponse
javax.servlet.ServletResponse getResponse() -
getStatusMessage
String getStatusMessage() -
headers
-
getHeader
- Specified by:
getHeaderin interfacejavax.servlet.http.HttpServletResponse
-
getHeaders
- Specified by:
getHeadersin interfacejavax.servlet.http.HttpServletResponse
-
getHeaderNames
Collection<String> getHeaderNames()- Specified by:
getHeaderNamesin interfacejavax.servlet.http.HttpServletResponse
-
setCharacterEncoding
- Specified by:
setCharacterEncodingin interfacejavax.servlet.ServletResponse
-
flushBuffer
- Specified by:
flushBufferin interfacejavax.servlet.ServletResponse- Throws:
IOException
-
getBufferSize
int getBufferSize()- Specified by:
getBufferSizein interfacejavax.servlet.ServletResponse
-
getCharacterEncoding
String getCharacterEncoding()- Specified by:
getCharacterEncodingin interfacejavax.servlet.ServletResponse
-
isDestroyable
boolean isDestroyable()Check if this object can be destroyed. Default is true. -
destroyable
-
getOutputStream
- Specified by:
getOutputStreamin interfacejavax.servlet.ServletResponse- Throws:
IOException
-
getWriter
- Specified by:
getWriterin interfacejavax.servlet.ServletResponse- Throws:
IOException
-
setContentLength
void setContentLength(int len) - Specified by:
setContentLengthin interfacejavax.servlet.ServletResponse
-
setContentType
- Specified by:
setContentTypein interfacejavax.servlet.ServletResponse
-
getContentType
String getContentType()- Specified by:
getContentTypein interfacejavax.servlet.ServletResponse
-
isCommitted
boolean isCommitted()- Specified by:
isCommittedin interfacejavax.servlet.ServletResponse
-
reset
void reset()- Specified by:
resetin interfacejavax.servlet.ServletResponse
-
resetBuffer
void resetBuffer()- Specified by:
resetBufferin interfacejavax.servlet.ServletResponse
-
setBufferSize
void setBufferSize(int size) - Specified by:
setBufferSizein interfacejavax.servlet.ServletResponse
-
setLocale
- Specified by:
setLocalein interfacejavax.servlet.ServletResponse
-
getLocale
Locale getLocale()- Specified by:
getLocalein interfacejavax.servlet.ServletResponse
-
getAsyncIOWriter
AsyncIOWriter getAsyncIOWriter()Return the underlyingAsyncIOWriter. -
asyncIOWriter
Set an implementation ofAsyncIOWriterthat will be invoked every time a write operation is ready to be processed.- Parameters:
asyncIOWriter- ofAsyncIOWriter- Returns:
- this
-
request
AtmosphereRequest request()Return the associatedAtmosphereRequest.- Returns:
- the associated
AtmosphereRequest
-
request
Set the associatedAtmosphereRequest.- Parameters:
atmosphereRequest- aAtmosphereRequest- Returns:
- this
-
close
Close the associatedAsyncIOWriter.- Throws:
IOException
-
closeStreamOrWriter
void closeStreamOrWriter()Close the associatedPrintWriterorOutputStream -
write
Write the String by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM- Parameters:
data- the String to write
-
write
Write the String by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the definedAsyncIOWriter.- Parameters:
data- the String to writewriteUsingOriginalResponse- if true, execute the write without invoking theAsyncIOWriter
-
write
Write the bytes by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM.- Parameters:
data- the bytes to write
-
write
Write the String by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the definedAsyncIOWriter.- Parameters:
data- the bytes to writewriteUsingOriginalResponse- if true, execute the write without invoking theAsyncIOWriter
-
write
Write the bytes by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM.- Parameters:
data- the bytes to writeoffset- the first byte position to writelength- the data length
-
write
Write the String by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the definedAsyncIOWriter.- Parameters:
data- the bytes to writeoffset- the first byte position to writelength- the data lengthwriteUsingOriginalResponse- if true, execute the write without invoking theAsyncIOWriter
-
resource
AtmosphereResource resource()TheAtmosphereResourceassociated 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 theAtmosphereResource.uuid()used by this object.- Returns:
- the
AtmosphereResource.uuid()used by this object.
-
toString
String toString()
-