Top Description Inners Fields Constructors Methods
org.eclipse.jetty.reactive.client.internal

public Class AdapterRequestContent

extends Object
implements Content
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.client.Request.Content, org.eclipse.jetty.io.Content.Source
Imports
org.eclipse.jetty.client.HttpClient, .Request, org.eclipse.jetty.io.Content, org.eclipse.jetty.reactive.client.ReactiveRequest, org.eclipse.jetty.util.thread.AutoLock, .SerializedInvoker, org.reactivestreams.Subscriber, .Subscription, org.slf4j.Logger, .LoggerFactory

A Request.Content whose source is a ReactiveRequest.Content.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
AdapterRequestContent.Bridge

A bridge between the Request.Content read by the HttpClient implementation and the ReactiveRequest.Content provided by applications.

Field Summary

Modifier and TypeField and Description
private AdapterRequestContent.Bridge
private static final Logger
private final ReactiveRequest.Content

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
demand(Runnable
the demand callback to invoke where there is a content chunk available
runnable
)

Implements org.eclipse.jetty.io.Content.Source.demand.

Demands to invoke the given demand callback parameter when a chunk of content is available.

public void
fail(Throwable
the cause of the failure
failure
)

Implements org.eclipse.jetty.io.Content.Source.fail.

Fails this content source with a last failure chunk, failing and discarding accumulated content chunks that were not yet read.

public String
public long
private AdapterRequestContent.Bridge
public Content.Chunk
read()

Implements org.eclipse.jetty.io.Content.Source.read.

Reads a chunk of content.

public boolean
rewind()

Overrides default org.eclipse.jetty.io.Content.Source.rewind.

Rewinds this content, if possible, so that subsequent reads return chunks starting from the beginning of this content.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bridgeback to summary
private AdapterRequestContent.Bridge bridge
loggerback to summary
private static final Logger logger
reactiveContentback to summary
private final ReactiveRequest.Content reactiveContent

Constructor Detail

AdapterRequestContentback to summary
public AdapterRequestContent(ReactiveRequest.Content content)

Method Detail

demandback to summary
public void demand(Runnable runnable)

Implements org.eclipse.jetty.io.Content.Source.demand.

Doc from org.eclipse.jetty.io.Content.Source.demand.

Demands to invoke the given demand callback parameter when a chunk of content is available.

See how to use this method idiomatically.

Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Runnable callback and a call to this method. Invocations of the passed Runnable are serialized and a callback for demand call is not invoked until any previous demand callback has returned. Thus the Runnable should not block waiting for a callback of a future demand call.

The demand callback may be invoked spuriously: a subsequent call to read() may return null.

Calling this method establishes a pending demand, which is fulfilled when the demand callback is invoked.

Calling this method when there is already a pending demand results in an IllegalStateException to be thrown.

If the invocation of the demand callback throws an exception, then fail(Throwable) is called.

Parameters
runnable:Runnable

the demand callback to invoke where there is a content chunk available

Annotations
@Override
failback to summary
public void fail(Throwable failure)

Implements org.eclipse.jetty.io.Content.Source.fail.

Doc from org.eclipse.jetty.io.Content.Source.fail.

Fails this content source with a last failure chunk, failing and discarding accumulated content chunks that were not yet read.

The failure may be notified to the content reader at a later time, when the content reader reads a content chunk, via a Chunk instance with a non null Chunk#getFailure().

If read() has returned a last chunk, this is a no operation.

Typical failure: the content being aborted by user code, or idle timeouts.

If this method has already been called, then it is a no operation.

Parameters
failure:Throwable

the cause of the failure

Annotations
@Override
getContentTypeback to summary
public String getContentType()

Overrides default org.eclipse.jetty.client.Request.Content.getContentType.

Returns:String

Doc from org.eclipse.jetty.client.Request.Content.getContentType.

the content type string such as "application/octet-stream" or "application/json;charset=UTF8", or null if the Content-Type header must not be set

Annotations
@Override
getLengthback to summary
public long getLength()

Overrides default org.eclipse.jetty.io.Content.Source.getLength.

Returns:long

Doc from org.eclipse.jetty.io.Content.Source.getLength.

the content length, if known, or -1 if the content length is unknown

Annotations
@Override
getOrCreateBridgeback to summary
private AdapterRequestContent.Bridge getOrCreateBridge()
readback to summary
public Content.Chunk read()

Implements org.eclipse.jetty.io.Content.Source.read.

Doc from org.eclipse.jetty.io.Content.Source.read.

Reads a chunk of content.

See how to use this method idiomatically.

The returned chunk could be:

  • null, to signal that there isn't a chunk of content available
  • an Chunk instance with non null Chunk#getFailure(), to signal that there was a failure trying to produce a chunk of content, or that the content production has been failed externally
  • a Chunk instance, containing the chunk of content.

Once a read returns an Chunk instance with non-null Chunk#getFailure() then if the failure is last further reads will continue to return the same failure chunk instance, otherwise further read() operations may return different non-failure chunks.

Once a read returns a last chunk, further reads will continue to return a last chunk (although the instance may be different).

The content reader code must ultimately arrange for a call to Chunk#release() on the returned Chunk.

Additionally, prior to the ultimate call to Chunk#release(), the reader code may make additional calls to Chunk#retain(), that must ultimately be matched by a correspondent number of calls to Chunk#release().

Concurrent reads from different threads are not recommended, as they are inherently in a race condition.

Reads performed outside the invocation context of a demand callback are allowed. However, reads performed with a pending demand are inherently in a race condition (the thread that reads with the thread that invokes the demand callback).

Returns:Content.Chunk

a chunk of content, possibly a failure instance, or null

Annotations
@Override
rewindback to summary
public boolean rewind()

Overrides default org.eclipse.jetty.io.Content.Source.rewind.

Doc from org.eclipse.jetty.io.Content.Source.rewind.

Rewinds this content, if possible, so that subsequent reads return chunks starting from the beginning of this content.

Returns:boolean

true if this content has been rewound, false if this content cannot be rewound

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.eclipse.jetty.reactive.client.internal back to summary

private Class AdapterRequestContent.Bridge

extends Object
implements Subscriber<Content.Chunk>
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.reactive.client.internal.AdapterRequestContent.Bridge
All Implemented Interfaces
org.reactivestreams.Subscriber

A bridge between the Request.Content read by the HttpClient implementation and the ReactiveRequest.Content provided by applications.

The first access to the Request.Content from the HttpClient implementation creates the bridge and forwards the access to it, calling either read() or demand(Runnable). Method read() returns the current Content.Chunk. Method demand(Runnable) forwards the demand to the ReactiveRequest.Content, which in turns calls onNext(Content.Chunk), providing the current chunk returned by read().

Field Summary

Modifier and TypeField and Description
private Content.Chunk
private boolean
private Runnable
private Throwable
private final SerializedInvoker
private final AutoLock
private Subscription

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
demand(Runnable onDemand)

private void
fail(Throwable cause)

private void
public void
onComplete()

Implements org.reactivestreams.Subscriber.onComplete.

Successful terminal state.
public void
onError(Throwable
the throwable signaled
error
)

Implements org.reactivestreams.Subscriber.onError.

Failed terminal state.
public void
onNext(Content.Chunk
the element signaled
c
)

Implements org.reactivestreams.Subscriber.onNext.

Data notification sent by the Publisher in response to requests to Subscription#request(long).
public void
private Content.Chunk
read()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

chunkback to summary
private Content.Chunk chunk
completeback to summary
private boolean complete
demandback to summary
private Runnable demand
failureback to summary
private Throwable failure
invokerback to summary
private final SerializedInvoker invoker
lockback to summary
private final AutoLock lock
subscriptionback to summary
private Subscription subscription

Constructor Detail

Bridgeback to summary
private Bridge()

Method Detail

demandback to summary
private void demand(Runnable onDemand)
failback to summary
private void fail(Throwable cause)
invokeDemandback to summary
private void invokeDemand(Runnable demand)
onCompleteback to summary
public void onComplete()

Implements org.reactivestreams.Subscriber.onComplete.

Doc from org.reactivestreams.Subscriber.onComplete.

Successful terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

Annotations
@Override
onErrorback to summary
public void onError(Throwable error)

Implements org.reactivestreams.Subscriber.onError.

Doc from org.reactivestreams.Subscriber.onError.

Failed terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

Parameters
error:Throwable

the throwable signaled

Annotations
@Override
onNextback to summary
public void onNext(Content.Chunk c)

Implements org.reactivestreams.Subscriber.onNext.

Doc from org.reactivestreams.Subscriber.onNext.

Data notification sent by the Publisher in response to requests to Subscription#request(long).

Parameters
c:Content.Chunk

the element signaled

Annotations
@Override
onSubscribeback to summary
public void onSubscribe(Subscription s)

Implements org.reactivestreams.Subscriber.onSubscribe.

Doc from org.reactivestreams.Subscriber.onSubscribe.

Invoked after calling Publisher#subscribe(Subscriber).

No data will start flowing until Subscription#request(long) is invoked.

It is the responsibility of this Subscriber instance to call Subscription#request(long) whenever more data is wanted.

The Publisher will send notifications only in response to Subscription#request(long).

Parameters
s:Subscription

the Subscription that allows requesting data via Subscription#request(long)

Annotations
@Override
readback to summary
private Content.Chunk read()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override