类 AbstractListenerReadPublisher<T>
- java.lang.Object
- org.springframework.http.server.reactive.AbstractListenerReadPublisher<T>
- 类型参数:
T
- the type of element signaled
- 所有已实现的接口:
org.reactivestreams.Publisher<T>
public abstract class AbstractListenerReadPublisher<T> extends Object implements org.reactivestreams.Publisher<T>
Abstract base class forPublisher
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.
- 从以下版本开始:
- 5.0
- 作者:
- Arjen Poutsma, Violeta Georgieva, Rossen Stoyanchev
字段概要
字段 修饰符和类型 字段 说明 protected static Log
rsReadLogger
Special logger for debugging Reactive Streams signals.
构造器概要
构造器 构造器 说明 AbstractListenerReadPublisher()
AbstractListenerReadPublisher(String logPrefix)
Create an instance with the given log prefix.
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected abstract void
checkOnDataAvailable()
Check if data is available and either callonDataAvailable()
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 viacheckOnDataAvailable()
, 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(org.reactivestreams.Subscriber<? super T> subscriber)
字段详细资料
rsReadLogger
protected static Log rsReadLogger
Special logger for debugging Reactive Streams signals.- 另请参阅:
LogDelegateFactory.getHiddenLog(Class)
,AbstractListenerWriteProcessor.rsWriteLogger
,AbstractListenerWriteFlushProcessor.rsWriteFlushLogger
,WriteResultPublisher.rsWriteResultLogger
构造器详细资料
AbstractListenerReadPublisher
public AbstractListenerReadPublisher()
AbstractListenerReadPublisher
public AbstractListenerReadPublisher(String logPrefix)
Create an instance with the given log prefix.- 从以下版本开始:
- 5.1
方法详细资料
getLogPrefix
public String getLogPrefix()
Return the configured log message prefix.- 从以下版本开始:
- 5.1
subscribe
public void subscribe(org.reactivestreams.Subscriber<? super T> subscriber)
- 指定者:
subscribe
在接口中org.reactivestreams.Publisher<T>
onDataAvailable
public final void onDataAvailable()
Invoked when reading is possible, either in the same thread after a check viacheckOnDataAvailable()
, or as a callback from the underlying container.
onAllDataRead
public void onAllDataRead()
Sub-classes can call this method to delegate a contain notification when all data has been read.
onError
public final void onError(Throwable ex)
Sub-classes can call this to delegate container error notifications.
checkOnDataAvailable
protected abstract void checkOnDataAvailable()
Check if data is available and either callonDataAvailable()
immediately or schedule a notification.
read
@Nullable protected abstract T read() throws IOException
Read once from the input, if possible.- 返回:
- the item that was read; or
null
- 抛出:
IOException
readingPaused
protected abstract void readingPaused()
Invoked when reading is paused due to a lack of demand.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 viacheckOnDataAvailable()
.- 从以下版本开始:
- 5.0.2
discardData
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.- 从以下版本开始:
- 5.0.11