public abstract class AbstractListenerWriteProcessor<T> extends Object implements org.reactivestreams.Processor<T,Void>
Processor
implementations that bridge between
event-listener write APIs and Reactive Streams.
Specifically a base class for writing to the HTTP response body with Servlet 3.1 non-blocking I/O and Undertow XNIO as well for writing WebSocket messages through the Java WebSocket API (JSR-356), Jetty, and Undertow.
Modifier and Type | Field and Description |
---|---|
protected T |
currentData |
protected Log |
logger |
Constructor and Description |
---|
AbstractListenerWriteProcessor() |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Listeners can call this method to cancel further writing.
|
protected abstract boolean |
isDataEmpty(T data)
Whether the given data item contains any actual data to be processed.
|
protected abstract boolean |
isWritePossible()
Whether writing is possible.
|
void |
onComplete() |
void |
onError(Throwable t) |
void |
onNext(T data) |
void |
onSubscribe(org.reactivestreams.Subscription subscription) |
void |
onWritePossible()
Listeners can call this to notify when writing is possible.
|
protected void |
receiveData(T data)
Called when a data item is received via
Subscriber.onNext(Object) |
protected abstract void |
releaseData()
Called when the current received data item can be released.
|
void |
subscribe(org.reactivestreams.Subscriber<? super Void> subscriber) |
protected abstract boolean |
write(T data)
Writes the given data to the output.
|
public final void onSubscribe(org.reactivestreams.Subscription subscription)
onSubscribe
in interface org.reactivestreams.Subscriber<T>
public final void onNext(T data)
onNext
in interface org.reactivestreams.Subscriber<T>
public final void onError(Throwable t)
onError
in interface org.reactivestreams.Subscriber<T>
public final void onComplete()
onComplete
in interface org.reactivestreams.Subscriber<T>
public final void subscribe(org.reactivestreams.Subscriber<? super Void> subscriber)
subscribe
in interface org.reactivestreams.Publisher<Void>
public final void onWritePossible()
public void cancel()
protected void receiveData(T data)
Subscriber.onNext(Object)
protected abstract void releaseData()
protected abstract boolean isDataEmpty(T data)
protected abstract boolean isWritePossible()
protected abstract boolean write(T data) throws IOException
data
- the data to writeIOException