Package io.helidon.common.reactive.valve
Class InputStreamValve
- java.lang.Object
-
- io.helidon.common.reactive.valve.InputStreamValve
-
- All Implemented Interfaces:
Pausable
,Valve<ByteBuffer>
public class InputStreamValve extends Object implements Valve<ByteBuffer>
The InputStreamValve is aByteBuffer
basedValve
that transforms a possibly blockingInputStream
into the Valve.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Collector<ByteBuffer,ByteArrayOutputStream,ByteBuffer>
byteBuffer2Collector()
A collector ofByteBuffer
instances into a singleByteBuffer
instance.static Collector<ByteBuffer,ByteArrayOutputStream,byte[]>
byteBufferByteArrayCollector()
A collector ofByteBuffer
instances into a single byte array.static Collector<ByteBuffer,ByteArrayOutputStream,String>
byteBufferStringCollector(Charset charset)
A collector ofByteBuffer
instances into aString
of the provided charset.protected boolean
canContinueProcessing()
Implementation oftryProcess()
which initially was accepted bycanProcess()
should call this method before every iteration to be sure, that processing can continue (is not paused).protected boolean
canProcess()
Implementation oftryProcess()
method should call this to reserve initial handle processing (if possible).protected Runnable
getOnComplete()
protected BiConsumer<T,Pausable>
getOnData()
protected Consumer<Throwable>
getOnError()
void
handle(BiConsumer<T,Pausable> onData, Consumer<Throwable> onError, Runnable onComplete)
protected void
handleError(Throwable thr)
protected ByteBuffer
moreData()
void
pause()
Pause data chunks flow untilPausable.resume()
.protected boolean
paused()
protected void
releaseProcessing()
void
resume()
Resume data chunks flow afterPausable.pause()
.protected void
tryProcess()
Implements item handling / processing.
-
-
-
Method Detail
-
moreData
protected ByteBuffer moreData() throws Throwable
- Throws:
Throwable
-
byteBufferStringCollector
public static Collector<ByteBuffer,ByteArrayOutputStream,String> byteBufferStringCollector(Charset charset)
A collector ofByteBuffer
instances into aString
of the provided charset.- Parameters:
charset
- the desired charset of the returned string- Returns:
- a string representation of the collected byte buffers
-
byteBuffer2Collector
public static Collector<ByteBuffer,ByteArrayOutputStream,ByteBuffer> byteBuffer2Collector()
A collector ofByteBuffer
instances into a singleByteBuffer
instance.- Returns:
- a single byte buffer from the collected byte buffers
-
byteBufferByteArrayCollector
public static Collector<ByteBuffer,ByteArrayOutputStream,byte[]> byteBufferByteArrayCollector()
A collector ofByteBuffer
instances into a single byte array.- Returns:
- a single byte array from the collected byte buffers
-
tryProcess
protected void tryProcess()
Implements item handling / processing. Implementation can usecanProcess()
andcanContinueProcessing()
method to ensure, that processing is done by a single thread at a time.
-
pause
public void pause()
Description copied from interface:Pausable
Pause data chunks flow untilPausable.resume()
.
-
resume
public void resume()
Description copied from interface:Pausable
Resume data chunks flow afterPausable.pause()
.
-
handle
public void handle(BiConsumer<T,Pausable> onData, Consumer<Throwable> onError, Runnable onComplete)
-
canProcess
protected boolean canProcess()
Implementation oftryProcess()
method should call this to reserve initial handle processing (if possible). The same method should callcanContinueProcessing()
before every iteration to be sure, that handle processing should continue.- Returns:
true
only if method can process (handle) item
-
canContinueProcessing
protected boolean canContinueProcessing()
Implementation oftryProcess()
which initially was accepted bycanProcess()
should call this method before every iteration to be sure, that processing can continue (is not paused).- Returns:
true
only if method can continue with handle processing
-
paused
protected boolean paused()
-
releaseProcessing
protected void releaseProcessing()
-
handleError
protected void handleError(Throwable thr)
-
getOnData
protected BiConsumer<T,Pausable> getOnData()
-
getOnComplete
protected Runnable getOnComplete()
-
-