public class ResponderTask extends java.lang.Object implements java.util.concurrent.Callable<ResponderTask.ResponderResult>
Responder
instance to define the interaction.
It looks for lines on the input stream that match the "inputSuccess" regular expression (e.g. password prompt). If it
detects the "inputFailure" regular expression, it fails. If successful, it writes the "inputString" to the output
stream.
ResponderTask.ResultHandler
is set, it will call the handleResult method after the response logic.
Callable
so it can be submitted to a ExecutorService
.
Modifier and Type | Class and Description |
---|---|
static class |
ResponderTask.ResponderResult
Result from a responder execution, which contains success, the original Responder, a failure reason if
unsuccessful and a boolean indicating if the process was interrupted.
|
static interface |
ResponderTask.ResultHandler
Handles result of responder thread run
|
static class |
ResponderTask.Sequence<T extends ResponderTask.SuccessResult>
Creates a callable by executing the first step, and only if successful executing the next step.
|
static interface |
ResponderTask.SuccessResult
Success/failure result interface
|
Constructor and Description |
---|
ResponderTask(Responder responder,
java.io.InputStream inputStream,
java.io.OutputStream outputStream,
ResponderTask.ResultHandler resultHandler)
Create a ResponderTask with a responder, io streams, and result handler which can be null.
|
Modifier and Type | Method and Description |
---|---|
ResponderTask.ResponderResult |
call() |
java.util.concurrent.Callable<ResponderTask.ResponderResult> |
createSequence(Responder responder)
Create a Callable that will execute another responder if this one is successful, with the same resultHandler for the
second one.
|
java.util.concurrent.Callable<ResponderTask.ResponderResult> |
createSequence(Responder responder,
ResponderTask.ResultHandler resultHandler)
Create a Callable that will execute another responder if this one is successful, with a specified resultHandler for the
second one.
|
java.lang.String |
getFailureReason() |
boolean |
isFailed() |
boolean |
isSuccess() |
public ResponderTask(Responder responder, java.io.InputStream inputStream, java.io.OutputStream outputStream, ResponderTask.ResultHandler resultHandler)
responder
- responderinputStream
- inputoutputStream
- outputresultHandler
- handlerpublic ResponderTask.ResponderResult call() throws java.lang.Exception
call
in interface java.util.concurrent.Callable<ResponderTask.ResponderResult>
java.lang.Exception
public boolean isFailed()
public java.util.concurrent.Callable<ResponderTask.ResponderResult> createSequence(Responder responder)
responder
- responderpublic java.util.concurrent.Callable<ResponderTask.ResponderResult> createSequence(Responder responder, ResponderTask.ResultHandler resultHandler)
responder
- responderresultHandler
- handlerpublic boolean isSuccess()
public java.lang.String getFailureReason()