abstract class BodyOutputStream
extends java.io.OutputStream
OutputStream
that adds method that allow to use the stream asynchronously.
It is inspired by and works in a very similar way as Servlet asynchronous streams introduced in Servlet 3.1.
The stream supports 2 modes SYNCHRONOUS and ASYNCHRONOUS.
The stream is one of the following 3 states:
setWriteListener(WriteListener)
is invoked before any of the write methods, it commits to ASYNCHRONOUS
mode and similarly if any of the write methods is invoked before setWriteListener(WriteListener)
,
it commits to SYNCHRONOUS mode.Constructor and Description |
---|
BodyOutputStream() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
isReady()
Returns true if data can be written without blocking else returns
false.
|
abstract void |
setWriteListener(WriteListener writeListener)
Instructs the stream to invoke the provided
WriteListener when it is possible to write. |
public abstract void setWriteListener(WriteListener writeListener)
WriteListener
when it is possible to write.
If the stream is in UNDECIDED state, invoking this method will commit the stream to ASYNCHRONOUS mode.writeListener
- the WriteListener
that should be notified
when it's possible to write.java.lang.IllegalStateException
- if one of the following conditions is true
java.lang.NullPointerException
- if writeListener is nullpublic abstract boolean isReady()
IllegalStateException
is thrown.true
if data can be obtained without blocking,
otherwise returns false
.