Flow.Publisher (Java SE 9 & JDK 9 ) (original) (raw)
- Type Parameters:
T
- the published item type
All Known Subinterfaces:[Flow.Processor](../../../java/util/concurrent/Flow.Processor.html "interface in java.util.concurrent")<T,R>
,[HttpRequest.BodyProcessor](../../../jdk/incubator/http/HttpRequest.BodyProcessor.html "interface in jdk.incubator.http")
All Known Implementing Classes:[SubmissionPublisher](../../../java/util/concurrent/SubmissionPublisher.html "class in java.util.concurrent")
Enclosing class:
Flow
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public static interface Flow.Publisher
A producer of items (and related control messages) received by Subscribers. Each current Flow.Subscriber receives the same items (via method onNext
) in the same order, unless drops or errors are encountered. If a Publisher encounters an error that does not allow items to be issued to a Subscriber, that Subscriber receives onError
, and then receives no further messages. Otherwise, when it is known that no further messages will be issued to it, a subscriber receives onComplete
. Publishers ensure that Subscriber method invocations for each subscription are strictly ordered in happens-before order.
Publishers may vary in policy about whether drops (failures to issue an item because of resource limitations) are treated as unrecoverable errors. Publishers may also vary about whether Subscribers receive items that were produced or available before they subscribed.
Method Summary
All Methods Instance Methods Abstract Methods
Modifier and Type Method Description void subscribe(Flow.Subscriber<? super T> subscriber) Adds the given Subscriber if possible. Method Detail
* #### subscribe void subscribe([Flow.Subscriber](../../../java/util/concurrent/Flow.Subscriber.html "interface in java.util.concurrent")<? super [T](../../../java/util/concurrent/Flow.Publisher.html "type parameter in Flow.Publisher")> subscriber) 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](../../../java/lang/IllegalStateException.html "class in java.lang"). Otherwise, the Subscriber's `onSubscribe` method is invoked with a new [Flow.Subscription](../../../java/util/concurrent/Flow.Subscription.html "interface in java.util.concurrent"). Subscribers may enable receiving items by invoking the `request` method of this Subscription, and may unsubscribe by invoking its `cancel` method. Parameters: `subscriber` \- the subscriber Throws: `[NullPointerException](../../../java/lang/NullPointerException.html "class in java.lang")` \- if subscriber is null
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.