|
||||||||||
| PREV CLASS NEXT CLASS | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ca.jcs.util.ExecHelper
public class ExecHelper
Spawns a process and then allows easy access to the stderr output it generates as a string. Stdout output can be accessed in one of two ways:
stdoutRecordSeparator is not null, then getStdoutRecordQueue() will return a
blocking queue from which the client can retrieve records as they become available. When EOF
is returned the queue has been drained completely.
stdoutRecordSeparator is null, then getStdoutOutput() will return all
of the text on the spawned process' stdout in a single string.
| Field Summary | |
|---|---|
protected String |
cmd
|
static String |
EOF
|
static String |
FEEDER_CLS
|
protected Condition |
feederStartCondition
|
protected Lock |
feederStartLock
|
static String |
GOBBLE_CLS
|
protected Logger |
log
|
static int |
numGobblers
|
protected String |
postfix
|
protected String |
prefix
|
protected String |
prompt
|
protected String |
response
|
protected BlockingQueue<String> |
stderrQueue
|
protected String |
stdinEofMsg
|
protected BlockingQueue<String> |
stdinQueue
|
protected com.ca.commons.functional.Fn<? super String,String> |
stdinStringMapper
|
protected BlockingQueue<String> |
stdoutRecordQueue
|
protected String |
stdoutRecordSeparator
|
| Constructor Summary | |
|---|---|
ExecHelper()
Create a simple exec helper where stdout and stderr text are returned as separate strings. |
|
ExecHelper(BlockingQueue<String> stdinQueue,
com.ca.commons.functional.Fn<? super String,String> mapper,
String eofMsg,
String stdoutRecordSeparator,
int maxSize,
Logger log)
Same as ExecHelper(String, int, org.slf4j.Logger) except allows input to be
read from a blocking queue and for processing of text as it is read from this queue, before being
written to the input stream of the spawned process. |
|
ExecHelper(Logger log)
Create a simple exec helper where stdout and stderr text are returned as separate strings and with logger provided. |
|
ExecHelper(String stdoutRecordSeparator,
int maxSize,
Logger log)
Create an exec helper where stderr text is returned as a simple string, but stdout text is broken up into separate records based on stdoutRecordSeparator and placed
on a blocking queue with maximum size maxSize. which can be retrieved by
getStdoutRecordQueue(). |
|
| Method Summary | |
|---|---|
String |
getStderrOutput()
|
BlockingQueue<String> |
getStderrQueue()
|
BlockingQueue<String> |
getStdinQueue()
|
com.ca.commons.functional.Fn<? super String,String> |
getStdinStringMapper()
|
String |
getStdoutOutput()
|
BlockingQueue<String> |
getStdoutRecordQueue()
|
String |
getStdoutRecordSeparator()
|
int |
run(List<String> exec)
|
int |
run(String exec)
|
protected int |
runStreams(Process proc)
|
void |
setPrompt(String prompt)
|
void |
setResponse(String response)
|
protected void |
signalFeederStart()
|
protected void |
waitForFeederStartSignal()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String EOF
protected String prefix
protected String postfix
protected String stdoutRecordSeparator
protected BlockingQueue<String> stdinQueue
protected com.ca.commons.functional.Fn<? super String,String> stdinStringMapper
protected String stdinEofMsg
protected BlockingQueue<String> stderrQueue
protected BlockingQueue<String> stdoutRecordQueue
protected String response
protected String prompt
protected Logger log
protected String cmd
protected final Lock feederStartLock
protected final Condition feederStartCondition
public static int numGobblers
public static final String GOBBLE_CLS
public static final String FEEDER_CLS
| Constructor Detail |
|---|
public ExecHelper()
public ExecHelper(Logger log)
public ExecHelper(String stdoutRecordSeparator,
int maxSize,
Logger log)
stdoutRecordSeparator and placed
on a blocking queue with maximum size maxSize. which can be retrieved by
getStdoutRecordQueue().
public ExecHelper(BlockingQueue<String> stdinQueue,
com.ca.commons.functional.Fn<? super String,String> mapper,
String eofMsg,
String stdoutRecordSeparator,
int maxSize,
Logger log)
ExecHelper(String, int, org.slf4j.Logger) except allows input to be
read from a blocking queue and for processing of text as it is read from this queue, before being
written to the input stream of the spawned process.
| Method Detail |
|---|
public void setResponse(String response)
public void setPrompt(String prompt)
public int run(List<String> exec)
throws Exception
Exception
public int run(String exec)
throws Exception
Exceptionpublic String getStdoutOutput()
public BlockingQueue<String> getStdinQueue()
public com.ca.commons.functional.Fn<? super String,String> getStdinStringMapper()
public String getStdoutRecordSeparator()
public BlockingQueue<String> getStdoutRecordQueue()
public BlockingQueue<String> getStderrQueue()
public String getStderrOutput()
protected int runStreams(Process proc)
throws InterruptedException
InterruptedException
protected void waitForFeederStartSignal()
throws InterruptedException
InterruptedExceptionprotected void signalFeederStart()
|
||||||||||
| PREV CLASS NEXT CLASS | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||