|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.enterprise.adaptor.prebuilt.StreamingCommand
public class StreamingCommand
Exec helper that allows easy handling of stdin, stdout, and stderr. Normally
you have to worry about deadlock when dealing with those streams (as
mentioned briefly in Process
), so this class handles that for you.
This class is very similar to Command
, except it allows streaming
stdin, stdout, and stderr, instead of buffering them.
Nested Class Summary | |
---|---|
static interface |
StreamingCommand.InputSource
Content source that generates content at the rate it can be consumed. |
static interface |
StreamingCommand.OutputSink
Content sink that consumes content as soon as it becomes available. |
Method Summary | |
---|---|
static int |
exec(String[] command,
File workingDir,
StreamingCommand.InputSource stdin,
StreamingCommand.OutputSink stdout,
StreamingCommand.OutputSink stderr)
Create process command starting in the workingDir and
providing stdin as input. |
static int |
exec(String[] command,
StreamingCommand.InputSource stdin,
StreamingCommand.OutputSink stdout,
StreamingCommand.OutputSink stderr)
Same as exec(command, null, stdin, stdout, stderr) . |
static StreamingCommand.InputSource |
streamInputSource(InputStream in)
InputStream to StreamingCommand.InputSource adaptor. |
static StreamingCommand.OutputSink |
streamOutputSink(OutputStream out)
OutputStream to StreamingCommand.OutputSink adaptor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int exec(String[] command, StreamingCommand.InputSource stdin, StreamingCommand.OutputSink stdout, StreamingCommand.OutputSink stderr) throws IOException, InterruptedException
exec(command, null, stdin, stdout, stderr)
.
IOException
InterruptedException
exec(String[], File, InputSource, OutputSink, OutputSink)
public static int exec(String[] command, File workingDir, StreamingCommand.InputSource stdin, StreamingCommand.OutputSink stdout, StreamingCommand.OutputSink stderr) throws IOException, InterruptedException
command
starting in the workingDir
and
providing stdin
as input. This method blocks until the process
exits. Stdout and stderr must be consumed via the StreamingCommand.OutputSink
s. If
stdin
, stdout
, or stderr
is null
, then a
bare implemention will be used.
IOException
- if creating process fails
InterruptedException
public static StreamingCommand.InputSource streamInputSource(InputStream in)
InputStream
to StreamingCommand.InputSource
adaptor.
public static StreamingCommand.OutputSink streamOutputSink(OutputStream out)
OutputStream
to StreamingCommand.OutputSink
adaptor.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |