Class ResponseListenerProcessor<T>
- All Implemented Interfaces:
EventListener,org.eclipse.jetty.client.api.Response.AsyncContentListener,org.eclipse.jetty.client.api.Response.BeginListener,org.eclipse.jetty.client.api.Response.CompleteListener,org.eclipse.jetty.client.api.Response.ContentListener,org.eclipse.jetty.client.api.Response.DemandedContentListener,org.eclipse.jetty.client.api.Response.FailureListener,org.eclipse.jetty.client.api.Response.HeaderListener,org.eclipse.jetty.client.api.Response.HeadersListener,org.eclipse.jetty.client.api.Response.Listener,org.eclipse.jetty.client.api.Response.ResponseListener,org.eclipse.jetty.client.api.Response.SuccessListener,org.reactivestreams.Processor<T,T>,org.reactivestreams.Publisher<T>,org.reactivestreams.Subscriber<T>,org.reactivestreams.Subscription
public class ResponseListenerProcessor<T> extends AbstractSingleProcessor<T,T> implements org.eclipse.jetty.client.api.Response.Listener
A Processor that listens for response events.
When this Processor is demanded data, it first sends the request and produces no data. When the response arrives, the application is invoked with a Publisher that produces response content chunks.
The application processes the response content chunks into some other data structure (for example, splits them further, or coalesce them into a single chunk) and returns the application Processor to this implementation, which then builds this chain:
HTTP response content chunks Publisher - (produces ContentChunks)
Application Processor - (processes ContentChunks and produces Ts)
ResponseListenerProcessor - (forwards Ts to application)
Application Subscriber - (consumes Ts)
Data flows from top to bottom, demand from bottom to top.
ResponseListenerProcessor acts as a "hot" publisher: it is returned to the application before the response content arrives so that the application can subscribe to it.
Any further data demand to this Processor is forwarded to the Application Processor, which in turn demands response content chunks. Response content chunks arrive to the Application Processor, which processes them and produces data that is forwarded to this Processor, which forwards it to the Application Subscriber.
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description ResponseListenerProcessor(ReactiveRequest request, BiFunction<ReactiveResponse,org.reactivestreams.Publisher<ContentChunk>,org.reactivestreams.Publisher<T>> contentFn) -
Method Summary
Modifier and Type Method Description voidonBeforeContent(org.eclipse.jetty.client.api.Response response, LongConsumer demand)voidonBegin(org.eclipse.jetty.client.api.Response response)voidonComplete(org.eclipse.jetty.client.api.Result result)voidonContent(org.eclipse.jetty.client.api.Response response, ByteBuffer content)voidonContent(org.eclipse.jetty.client.api.Response response, ByteBuffer buffer, org.eclipse.jetty.util.Callback callback)voidonContent(org.eclipse.jetty.client.api.Response response, LongConsumer demand, ByteBuffer buffer, org.eclipse.jetty.util.Callback callback)voidonFailure(org.eclipse.jetty.client.api.Response response, Throwable failure)booleanonHeader(org.eclipse.jetty.client.api.Response response, org.eclipse.jetty.http.HttpField field)voidonHeaders(org.eclipse.jetty.client.api.Response response)voidonNext(T t)protected voidonRequest(org.reactivestreams.Subscriber<? super T> subscriber, long n)voidonSuccess(org.eclipse.jetty.client.api.Response response)StringtoString()Methods inherited from class org.eclipse.jetty.reactive.client.internal.AbstractSingleProcessor
cancel, downStream, downStreamOnNext, onComplete, onError, onFailure, onSubscribe, upStream, upStreamRequestMethods inherited from class org.eclipse.jetty.reactive.client.internal.AbstractSinglePublisher
isCancelled, request, subscribe, subscriber
-
Constructor Details
-
ResponseListenerProcessor
public ResponseListenerProcessor(ReactiveRequest request, BiFunction<ReactiveResponse,org.reactivestreams.Publisher<ContentChunk>,org.reactivestreams.Publisher<T>> contentFn)
-
-
Method Details
-
onBegin
public void onBegin(org.eclipse.jetty.client.api.Response response)- Specified by:
onBeginin interfaceorg.eclipse.jetty.client.api.Response.BeginListener- Specified by:
onBeginin interfaceorg.eclipse.jetty.client.api.Response.Listener
-
onHeader
public boolean onHeader(org.eclipse.jetty.client.api.Response response, org.eclipse.jetty.http.HttpField field)- Specified by:
onHeaderin interfaceorg.eclipse.jetty.client.api.Response.HeaderListener- Specified by:
onHeaderin interfaceorg.eclipse.jetty.client.api.Response.Listener
-
onHeaders
public void onHeaders(org.eclipse.jetty.client.api.Response response)- Specified by:
onHeadersin interfaceorg.eclipse.jetty.client.api.Response.HeadersListener- Specified by:
onHeadersin interfaceorg.eclipse.jetty.client.api.Response.Listener
-
onBeforeContent
- Specified by:
onBeforeContentin interfaceorg.eclipse.jetty.client.api.Response.DemandedContentListener
-
onContent
- Specified by:
onContentin interfaceorg.eclipse.jetty.client.api.Response.ContentListener- Specified by:
onContentin interfaceorg.eclipse.jetty.client.api.Response.Listener
-
onContent
public void onContent(org.eclipse.jetty.client.api.Response response, ByteBuffer buffer, org.eclipse.jetty.util.Callback callback)- Specified by:
onContentin interfaceorg.eclipse.jetty.client.api.Response.AsyncContentListener- Specified by:
onContentin interfaceorg.eclipse.jetty.client.api.Response.ContentListener
-
onContent
public void onContent(org.eclipse.jetty.client.api.Response response, LongConsumer demand, ByteBuffer buffer, org.eclipse.jetty.util.Callback callback)- Specified by:
onContentin interfaceorg.eclipse.jetty.client.api.Response.AsyncContentListener- Specified by:
onContentin interfaceorg.eclipse.jetty.client.api.Response.DemandedContentListener
-
onSuccess
public void onSuccess(org.eclipse.jetty.client.api.Response response)- Specified by:
onSuccessin interfaceorg.eclipse.jetty.client.api.Response.Listener- Specified by:
onSuccessin interfaceorg.eclipse.jetty.client.api.Response.SuccessListener
-
onFailure
- Specified by:
onFailurein interfaceorg.eclipse.jetty.client.api.Response.FailureListener- Specified by:
onFailurein interfaceorg.eclipse.jetty.client.api.Response.Listener
-
onComplete
public void onComplete(org.eclipse.jetty.client.api.Result result)- Specified by:
onCompletein interfaceorg.eclipse.jetty.client.api.Response.CompleteListener- Specified by:
onCompletein interfaceorg.eclipse.jetty.client.api.Response.Listener
-
onRequest
- Overrides:
onRequestin classAbstractSingleProcessor<T,T>
-
onNext
- Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<T>
-
toString
- Overrides:
toStringin classAbstractSingleProcessor<T,T>
-