abstract class BodyInputStream extends NonBlockingInputStream
NonBlockingInputStream
that adds methods that enable using the stream asynchronously.
The asynchronous mode is inspired by and works in a very similar way as Servlet asynchronous streams introduced in Servlet
3.1.
The stream supports 2 modes of operation SYNCHRONOUS and ASYNCHRONOUS.
The stream is one of the following 3 states:
setReadListener(ReadListener)
is invoked before any of the read or tryRead methods, it commits to ASYNCHRONOUS
mode and similarly if any of the read or tryRead methods is invoked before setReadListener(ReadListener)
,
it commits to SYNCHRONOUS mode.NOTHING
Constructor and Description |
---|
BodyInputStream() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
isReady()
Returns true if data can be read without blocking else returns
false.
|
abstract void |
setReadListener(ReadListener readListener)
Instructs the stream to invoke the provided
ReadListener when it is possible to read. |
available, tryRead, tryRead, tryRead
public abstract boolean isReady()
IllegalStateException
is thrown.true
if data can be obtained without blocking,
otherwise returns false
.public abstract void setReadListener(ReadListener readListener)
ReadListener
when it is possible to read.
If the stream is in UNDECIDED state, invoking this method will commit the stream to ASYNCHRONOUS mode.readListener
- the ReadListener
that should be notified
when it's possible to read.java.lang.IllegalStateException
- if one of the following conditions is true
java.lang.NullPointerException
- if readListener is null