public abstract class BaseDataReader
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BaseDataReader.AdaptiveSleepingPolicy
Deprecated.
use one of default policies (recommended) or implement your own
|
static interface |
BaseDataReader.SleepingPolicy |
Modifier and Type | Field and Description |
---|---|
protected boolean |
isStopped |
protected BaseDataReader.SleepingPolicy |
mySleepingPolicy |
protected java.lang.Object |
mySleepMonitor |
Constructor and Description |
---|
BaseDataReader(BaseDataReader.SleepingPolicy sleepingPolicy) |
Modifier and Type | Method and Description |
---|---|
protected void |
beforeSleeping(boolean hasJustReadSomething) |
protected abstract void |
close() |
protected void |
doRun() |
protected abstract java.util.concurrent.Future<?> |
executeOnPooledThread(java.lang.Runnable runnable) |
protected void |
flush() |
protected boolean |
readAvailable()
Please don't override this method as the BaseOSProcessProcessHandler assumes that it can be two reading modes: blocking and non-blocking.
|
protected boolean |
readAvailableBlocking()
Reader in a blocking mode blocks on IO read operation until data is received.
|
protected boolean |
readAvailableNonBlocking()
Non-blocking read returns the control back to the process handler when there is no data to read.
|
protected void |
start()
Deprecated.
use
start(String) |
protected void |
start(java.lang.String presentableName) |
void |
stop() |
void |
waitFor() |
void |
waitFor(long timeout,
java.util.concurrent.TimeUnit unit) |
protected final BaseDataReader.SleepingPolicy mySleepingPolicy
protected final java.lang.Object mySleepMonitor
protected volatile boolean isStopped
public BaseDataReader(BaseDataReader.SleepingPolicy sleepingPolicy)
sleepingPolicy
- default is BaseDataReader.SleepingPolicy.NON_BLOCKING
for the reasons described on BaseDataReader.SleepingPolicy
which may be changed
in future versions.protected void start(java.lang.String presentableName)
protected boolean readAvailable() throws java.io.IOException
readAvailableBlocking()
and readAvailableNonBlocking()
instead.
If the process handler assumes that reader handles the blocking mode, while it doesn't, it will result into premature stream close.java.io.IOException
- if an exception during IO happenedBaseDataReader.SleepingPolicy
protected boolean readAvailableNonBlocking() throws java.io.IOException
java.io.IOException
BaseDataReader.SleepingPolicy.NON_BLOCKING
protected boolean readAvailableBlocking() throws java.io.IOException
java.io.IOException
BaseDataReader.SleepingPolicy.BLOCKING
protected abstract java.util.concurrent.Future<?> executeOnPooledThread(java.lang.Runnable runnable)
protected void doRun()
protected void flush()
protected void beforeSleeping(boolean hasJustReadSomething)
protected abstract void close() throws java.io.IOException
java.io.IOException
public void stop()
public void waitFor() throws java.lang.InterruptedException
java.lang.InterruptedException
public void waitFor(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
@Deprecated protected void start()
start(String)