Package org.atmosphere.cpr
Interface AtmosphereResponse
- All Superinterfaces:
HttpServletResponse,ServletResponse
- All Known Implementing Classes:
AtmosphereResponseImpl
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.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interfaceAtmosphereResponse.WriteAction<E extends Exception>Something run while the response writes through another writer (writeThrough(org.atmosphere.cpr.AsyncIOWriter, org.atmosphere.cpr.AtmosphereResponse.WriteAction<E>)). -
Field Summary
Fields inherited from interface jakarta.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 TypeMethodDescriptionasyncIOWriter(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 associatedorinvalid reference
PrintWriterOutputStreamdelegateToNativeResponse(boolean delegateToNativeResponse) voiddestroy()voiddestroy(boolean force) destroyable(boolean destroyable) booleanReturn the underlyingAsyncIOWriter.headers()booleanCheck if this object can be destroyed.request()Return the associatedAtmosphereRequest.request(AtmosphereRequest atmosphereRequest) Set the associatedAtmosphereRequest.resource()TheAtmosphereResourceassociated with this request.voidsetResponse(ServletResponse response) uuid()Return theAtmosphereResource.uuid()used by this object.write(byte[] data) Write the bytes by either using theorinvalid reference
PrintWriterOutputStream.write(byte[] data, boolean writeUsingOriginalResponse) Write the String by either using theorinvalid reference
PrintWriterOutputStream.write(byte[] data, int offset, int length) Write the bytes by either using theorinvalid reference
PrintWriterOutputStream.write(byte[] data, int offset, int length, boolean writeUsingOriginalResponse) Write the String by either using theorinvalid reference
PrintWriterOutputStream.Write the String by either using theorinvalid reference
PrintWriterOutputStream.Write the String by either using theorinvalid reference
PrintWriterOutputStream.default <E extends Exception>
voidwriteThrough(AsyncIOWriter writer, AtmosphereResponse.WriteAction<E> action) Runactionwith this response writing throughwriteron the calling thread only, then through its own writer again; another thread writing to the response meanwhile writes through its own writer.Methods inherited from interface jakarta.servlet.http.HttpServletResponse
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, getHeader, getHeaderNames, getHeaders, getStatus, getTrailerFields, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus, setStatus, setTrailerFieldsMethods inherited from interface jakarta.servlet.ServletResponse
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale
-
Method Details
-
destroy
void destroy() -
destroy
void destroy(boolean force) -
destroyed
boolean destroyed() -
delegateToNativeResponse
-
getResponse
ServletResponse getResponse() -
getStatusMessage
String getStatusMessage() -
headers
-
isDestroyable
boolean isDestroyable()Check if this object can be destroyed. Default is true. -
destroyable
-
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
-
writeThrough
default <E extends Exception> void writeThrough(AsyncIOWriter writer, AtmosphereResponse.WriteAction<E> action) throws E Runactionwith this response writing throughwriteron the calling thread only, then through its own writer again; another thread writing to the response meanwhile writes through its own writer. This default installswriterfor every thread whileactionruns.- Type Parameters:
E- whatactionmay throw- Parameters:
writer- the writer to write through whileactionrunsaction- what writes to the response throughwriter- Throws:
E- whenactionthrows it
-
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 associatedorinvalid reference
PrintWriterOutputStream -
write
Write the String by either using theorinvalid reference
PrintWriterOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM- Parameters:
data- the String to write
-
write
Write the String by either using theorinvalid reference
PrintWriterOutputStream. 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 theorinvalid reference
PrintWriterOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM.- Parameters:
data- the bytes to write
-
write
Write the String by either using theorinvalid reference
PrintWriterOutputStream. 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 theorinvalid reference
PrintWriterOutputStream. 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 theorinvalid reference
PrintWriterOutputStream. 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
-
uuid
String uuid()Return theAtmosphereResource.uuid()used by this object.- Returns:
- the
AtmosphereResource.uuid()used by this object.
-