public abstract class AbstractListenerWriteProcessor<T>
extends java.lang.Object
implements org.reactivestreams.Processor<T,java.lang.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.
| Constructor and Description |
|---|
AbstractListenerWriteProcessor() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Invoked during an error or completion callback from the underlying
container to cancel the upstream subscription.
|
protected void |
dataReceived(T data)
Template method invoked after a data item to write is received via
Subscriber.onNext(Object). |
protected abstract boolean |
isDataEmpty(T data)
Whether the given data item has any content to write.
|
protected abstract boolean |
isWritePossible()
Whether writing is possible.
|
void |
onComplete()
Completion signal from the upstream, write Publisher.
|
void |
onError(java.lang.Throwable ex)
Error signal from the upstream, write Publisher.
|
void |
onNext(T data) |
void |
onSubscribe(org.reactivestreams.Subscription subscription) |
void |
onWritePossible()
Invoked when writing is possible, either in the same thread after a check
via
isWritePossible(), or as a callback from the underlying
container. |
void |
subscribe(org.reactivestreams.Subscriber<? super java.lang.Void> subscriber) |
protected abstract boolean |
write(T data)
Write the given item.
|
protected void |
writingComplete()
Invoked after onComplete or onError notification.
|
protected void |
writingFailed(java.lang.Throwable ex)
Invoked when an I/O error occurs during a write.
|
protected void |
writingPaused()
Deprecated.
originally introduced for Undertow to stop write notifications
when no data is available, but deprecated as of as of 5.0.6 since constant
switching on every requested item causes a significant slowdown.
|
protected final Log logger
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(java.lang.Throwable ex)
onError in interface org.reactivestreams.Subscriber<T>public final void onComplete()
onComplete in interface org.reactivestreams.Subscriber<T>public final void onWritePossible()
isWritePossible(), or as a callback from the underlying
container.public void cancel()
public final void subscribe(org.reactivestreams.Subscriber<? super java.lang.Void> subscriber)
subscribe in interface org.reactivestreams.Publisher<java.lang.Void>protected abstract boolean isDataEmpty(T data)
protected void dataReceived(T data)
Subscriber.onNext(Object). The default implementation saves the
data item for writing once that is possible.protected abstract boolean isWritePossible()
protected abstract boolean write(T data) throws java.io.IOException
Note: Sub-classes are responsible for releasing any data buffer associated with the item, once fully written, if pooled buffers apply to the underlying container.
data - the item to writetrue), or or otherwise if more writes are required.java.io.IOException@Deprecated protected void writingPaused()
The default implementation is a no-op.
protected void writingComplete()
The default implementation is a no-op.
protected void writingFailed(java.lang.Throwable ex)
Defaults to no-op.