public abstract class AbstractListenerReadPublisher<T>
extends java.lang.Object
Publisher
implementations that bridge between
event-listener read APIs and Reactive Streams.
Specifically a base class for reading from the HTTP request body with Servlet 3.1 non-blocking I/O and Undertow XNIO as well as handling incoming WebSocket messages with standard Java WebSocket (JSR-356), Jetty, and Undertow.
Modifier and Type | Class and Description |
---|---|
private static class |
AbstractListenerReadPublisher.ReadSubscription |
private static class |
AbstractListenerReadPublisher.State
Represents a state for the
Publisher to be in. |
Modifier and Type | Field and Description |
---|---|
private long |
demand |
private static java.util.concurrent.atomic.AtomicLongFieldUpdater<AbstractListenerReadPublisher> |
DEMAND_FIELD_UPDATER |
protected Log |
logger |
private java.util.concurrent.atomic.AtomicReference<AbstractListenerReadPublisher.State> |
state |
private <any> |
subscriber |
Constructor and Description |
---|
AbstractListenerReadPublisher() |
Modifier and Type | Method and Description |
---|---|
private boolean |
changeState(AbstractListenerReadPublisher.State oldState,
AbstractListenerReadPublisher.State newState) |
protected abstract void |
checkOnDataAvailable() |
void |
onAllDataRead()
Listeners can call this to notify when all data has been read.
|
void |
onDataAvailable()
Listeners can call this to notify when reading is possible.
|
void |
onError(java.lang.Throwable t)
Listeners can call this to notify when a read error has occurred.
|
protected abstract T |
read()
Reads a data from the input, if possible.
|
private boolean |
readAndPublish()
Read and publish data from the input.
|
void |
subscribe(<any> subscriber) |
protected final Log logger
private final java.util.concurrent.atomic.AtomicReference<AbstractListenerReadPublisher.State> state
private volatile long demand
private static final java.util.concurrent.atomic.AtomicLongFieldUpdater<AbstractListenerReadPublisher> DEMAND_FIELD_UPDATER
private <any> subscriber
public void subscribe(<any> subscriber)
public final void onDataAvailable()
public void onAllDataRead()
public final void onError(java.lang.Throwable t)
protected abstract void checkOnDataAvailable()
protected abstract T read() throws java.io.IOException
null
java.io.IOException
private boolean readAndPublish() throws java.io.IOException
true
if there is more demand; false
otherwisejava.io.IOException
private boolean changeState(AbstractListenerReadPublisher.State oldState, AbstractListenerReadPublisher.State newState)