T
- the type of element signaledpublic abstract class AbstractListenerReadPublisher<T> extends Object implements Publisher<T>
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 | Field and Description |
---|---|
protected static Log |
rsReadLogger
Special logger for debugging Reactive Streams signals.
|
Constructor and Description |
---|
AbstractListenerReadPublisher() |
AbstractListenerReadPublisher(String logPrefix)
Create an instance with the given log prefix.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
checkOnDataAvailable()
Check if data is available and either call
onDataAvailable()
immediately or schedule a notification. |
protected abstract void |
discardData()
Invoked after an I/O read error from the underlying server or after a
cancellation signal from the downstream consumer to allow sub-classes
to discard any current cached data they might have.
|
String |
getLogPrefix()
Return the configured log message prefix.
|
void |
onAllDataRead()
Sub-classes can call this method to delegate a contain notification when
all data has been read.
|
void |
onDataAvailable()
Invoked when reading is possible, either in the same thread after a check
via
checkOnDataAvailable() , or as a callback from the underlying
container. |
void |
onError(Throwable ex)
Sub-classes can call this to delegate container error notifications.
|
protected abstract T |
read()
Read once from the input, if possible.
|
protected abstract void |
readingPaused()
Invoked when reading is paused due to a lack of demand.
|
void |
subscribe(Subscriber<? super T> subscriber) |
protected static Log rsReadLogger
LogDelegateFactory.getHiddenLog(Class)
,
AbstractListenerWriteProcessor.rsWriteLogger
,
AbstractListenerWriteFlushProcessor.rsWriteFlushLogger
,
WriteResultPublisher.rsWriteResultLogger
public AbstractListenerReadPublisher()
public AbstractListenerReadPublisher(String logPrefix)
public String getLogPrefix()
public void subscribe(Subscriber<? super T> subscriber)
public final void onDataAvailable()
checkOnDataAvailable()
, or as a callback from the underlying
container.public void onAllDataRead()
public final void onError(Throwable ex)
protected abstract void checkOnDataAvailable()
onDataAvailable()
immediately or schedule a notification.@Nullable protected abstract T read() throws IOException
null
IOException
protected abstract void readingPaused()
Note: This method is guaranteed not to compete with
checkOnDataAvailable()
so it can be used to safely suspend
reading, if the underlying API supports it, i.e. without competing with
an implicit call to resume via checkOnDataAvailable()
.
protected abstract void discardData()