Top Description Inners Fields Constructors Methods
org.eclipse.jetty.io.content

public Class ContentSourcePublisher

extends Object
implements Flow.Publisher<Content.Chunk>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Flow.Publisher
Imports
java.util.concurrent.Flow, org.eclipse.jetty.io.Content, org.eclipse.jetty.util.MathUtils, org.eclipse.jetty.util.thread.AutoLock

Wraps a Content.Source as a Flow.Publisher. When content is requested via Flow.Subscription#request(long), it is read from the passed Content.Source and passed to Flow.Subscriber#onNext(Object). If no content is available, then the Content.Source#demand(Runnable) method is used to ultimately call Flow.Subscriber#onNext(Object) once content is available.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Content.Source

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
subscribe(Flow.Subscriber<? super Content.Chunk>
the subscriber
subscriber
)

Implements java.util.concurrent.Flow.Publisher.subscribe.

Adds the given Subscriber if possible.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
private final Content.Source content

Constructor Detail

ContentSourcePublisherback to summary
public ContentSourcePublisher(Content.Source content)

Method Detail

subscribeback to summary
public void subscribe(Flow.Subscriber<? super Content.Chunk> subscriber)

Implements java.util.concurrent.Flow.Publisher.subscribe.

Doc from java.util.concurrent.Flow.Publisher.subscribe.

Adds the given Subscriber if possible. If already subscribed, or the attempt to subscribe fails due to policy violations or errors, the Subscriber's onError method is invoked with an IllegalStateException. Otherwise, the Subscriber's onSubscribe method is invoked with a new Subscription. Subscribers may enable receiving items by invoking the request method of this Subscription, and may unsubscribe by invoking its cancel method.

Parameters
subscriber:Flow.Subscriber<? super Content.Chunk>

the subscriber

Annotations
@Override
org.eclipse.jetty.io.content back to summary

private Class ContentSourcePublisher.SubscriptionImpl

extends Object
implements Subscription
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.io.content.ContentSourcePublisher.SubscriptionImpl
All Implemented Interfaces
java.util.concurrent.Flow.Subscription

Field Summary

Modifier and TypeField and Description
private boolean
private final Content.Source
private long
private final AutoLock
private boolean
private final Flow.Subscriber<? super Content.Chunk>
private boolean

Constructor Summary

AccessConstructor and Description
public
SubscriptionImpl(Content.Source content, Flow.Subscriber<? super Content.Chunk> subscriber)

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

Implements java.util.concurrent.Flow.Subscription.cancel.

Causes the Subscriber to (eventually) stop receiving messages.

private void
public void
request(long
the increment of demand; a value of Long.MAX_VALUE may be considered as effectively unbounded
n
)

Implements java.util.concurrent.Flow.Subscription.request.

Adds the given number n of items to the current unfulfilled demand for this subscription.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cancelledback to summary
private boolean cancelled
contentback to summary
private final Content.Source content
demandback to summary
private long demand
lockback to summary
private final AutoLock lock
stalledback to summary
private boolean stalled
subscriberback to summary
private final Flow.Subscriber<? super Content.Chunk> subscriber
terminatedback to summary
private boolean terminated

Constructor Detail

SubscriptionImplback to summary
public SubscriptionImpl(Content.Source content, Flow.Subscriber<? super Content.Chunk> subscriber)

Method Detail

cancelback to summary
public void cancel()

Implements java.util.concurrent.Flow.Subscription.cancel.

Doc from java.util.concurrent.Flow.Subscription.cancel.

Causes the Subscriber to (eventually) stop receiving messages. Implementation is best-effort -- additional messages may be received after invoking this method. A cancelled subscription need not ever receive an onComplete or onError signal.

Annotations
@Override
processback to summary
private void process()
requestback to summary
public void request(long n)

Implements java.util.concurrent.Flow.Subscription.request.

Doc from java.util.concurrent.Flow.Subscription.request.

Adds the given number n of items to the current unfulfilled demand for this subscription. If n is less than or equal to zero, the Subscriber will receive an onError signal with an IllegalArgumentException argument. Otherwise, the Subscriber will receive up to n additional onNext invocations (or fewer if terminated).

Parameters
n:long

the increment of demand; a value of Long.MAX_VALUE may be considered as effectively unbounded

Annotations
@Override
terminateback to summary
private void terminate()