Package io.helidon.media.common
Class PublisherInputStream
- java.lang.Object
-
- java.io.InputStream
-
- io.helidon.media.common.PublisherInputStream
-
- All Implemented Interfaces:
Flow.Publisher<DataChunk>,Closeable,AutoCloseable
public class PublisherInputStream extends InputStream implements Flow.Publisher<DataChunk>
Ansubscriberthat can subscribe to a source ofByteBufferdata chunks and then make them available for consumption via standard blockingInputStreamAPI.
-
-
Constructor Summary
Constructors Constructor Description PublisherInputStream(Flow.Publisher<DataChunk> originalPublisher)Wraps the supplied publisher and adds a blockingInputStreambased nature.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intread()voidsubscribe(Flow.Subscriber<? super DataChunk> subscriber)Adds the given Subscriber if possible.-
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
PublisherInputStream
public PublisherInputStream(Flow.Publisher<DataChunk> originalPublisher)
Wraps the supplied publisher and adds a blockingInputStreambased nature. It is illegal to subscribe to the returned publisher.- Parameters:
originalPublisher- the original publisher to wrap
-
-
Method Detail
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
subscribe
public void subscribe(Flow.Subscriber<? super DataChunk> subscriber)
Description copied from interface:Flow.PublisherAdds the given Subscriber if possible. If already subscribed, or the attempt to subscribe fails due to policy violations or errors, the Subscriber'sonErrormethod is invoked with anIllegalStateException. Otherwise, the Subscriber'sonSubscribemethod is invoked with a newFlow.Subscription. Subscribers may enable receiving items by invoking therequestmethod of this Subscription, and may unsubscribe by invoking itscancelmethod.- Specified by:
subscribein interfaceFlow.Publisher<DataChunk>- Parameters:
subscriber- the subscriber
-
-