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.

  • Constructor Details

  • Method Details

    • onBegin

      public void onBegin​(org.eclipse.jetty.client.api.Response response)
      Specified by:
      onBegin in interface org.eclipse.jetty.client.api.Response.BeginListener
      Specified by:
      onBegin in interface org.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:
      onHeader in interface org.eclipse.jetty.client.api.Response.HeaderListener
      Specified by:
      onHeader in interface org.eclipse.jetty.client.api.Response.Listener
    • onHeaders

      public void onHeaders​(org.eclipse.jetty.client.api.Response response)
      Specified by:
      onHeaders in interface org.eclipse.jetty.client.api.Response.HeadersListener
      Specified by:
      onHeaders in interface org.eclipse.jetty.client.api.Response.Listener
    • onBeforeContent

      public void onBeforeContent​(org.eclipse.jetty.client.api.Response response, LongConsumer demand)
      Specified by:
      onBeforeContent in interface org.eclipse.jetty.client.api.Response.DemandedContentListener
    • onContent

      public void onContent​(org.eclipse.jetty.client.api.Response response, ByteBuffer content)
      Specified by:
      onContent in interface org.eclipse.jetty.client.api.Response.ContentListener
      Specified by:
      onContent in interface org.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:
      onContent in interface org.eclipse.jetty.client.api.Response.AsyncContentListener
      Specified by:
      onContent in interface org.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:
      onContent in interface org.eclipse.jetty.client.api.Response.AsyncContentListener
      Specified by:
      onContent in interface org.eclipse.jetty.client.api.Response.DemandedContentListener
    • onSuccess

      public void onSuccess​(org.eclipse.jetty.client.api.Response response)
      Specified by:
      onSuccess in interface org.eclipse.jetty.client.api.Response.Listener
      Specified by:
      onSuccess in interface org.eclipse.jetty.client.api.Response.SuccessListener
    • onFailure

      public void onFailure​(org.eclipse.jetty.client.api.Response response, Throwable failure)
      Specified by:
      onFailure in interface org.eclipse.jetty.client.api.Response.FailureListener
      Specified by:
      onFailure in interface org.eclipse.jetty.client.api.Response.Listener
    • onComplete

      public void onComplete​(org.eclipse.jetty.client.api.Result result)
      Specified by:
      onComplete in interface org.eclipse.jetty.client.api.Response.CompleteListener
      Specified by:
      onComplete in interface org.eclipse.jetty.client.api.Response.Listener
    • onRequest

      protected void onRequest​(org.reactivestreams.Subscriber<? super T> subscriber, long n)
      Overrides:
      onRequest in class AbstractSingleProcessor<T,​T>
    • onNext

      public void onNext​(T t)
      Specified by:
      onNext in interface org.reactivestreams.Subscriber<T>
    • toString

      public String toString()
      Overrides:
      toString in class AbstractSingleProcessor<T,​T>