| Modifier and Type | Class and Description |
|---|---|
| public static class | ProcessHandler.
Subprocess attributes passed to
|
| public static class | ProcessHandler.
Represents a source of subprocess input or a destination of subprocess output. |
| Modifier and Type | Method and Description |
|---|---|
| public Process | start(ProcessHandler.
the subprocess attributes commandA request to start a new subprocess with given attributes. |
| start | back to summary |
|---|---|
| public Process start(ProcessHandler. A request to start a new subprocess with given attributes.
The default implementation uses
public Process start(ProcessCommand command) throws IOException {
ProcessBuilder builder = new ProcessBuilder(command.getCommand()).redirectErrorStream(command.isRedirectErrorStream()).redirectInput(
asProcessBuilderRedirect(command.getInputRedirect())).redirectOutput(asProcessBuilderRedirect(command.getOutputRedirect())).redirectError(
asProcessBuilderRedirect(command.getErrorRedirect()));
Map<String, String> env = builder.environment();
env.clear();
env.putAll(command.getEnvironment());
String cwd = command.getDirectory();
if (cwd != null) {
builder.directory(Paths.get(cwd).toFile());
}
return builder.start();
}
private static java.lang.ProcessBuilder.Redirect asProcessBuilderRedirect(ProcessHandler.Redirect redirect) {
if (redirect == ProcessHandler.Redirect.PIPE) {
return java.lang.ProcessBuilder.Redirect.PIPE;
} else if (redirect == ProcessHandler.Redirect.INHERIT) {
return java.lang.ProcessBuilder.Redirect.INHERIT;
} else {
throw new IllegalStateException("Unsupported redirect: " + redirect);
}
}
| |
start method.
| Modifier and Type | Field and Description |
|---|---|
| private List | |
| private String | |
| private Map | |
| private ProcessHandler. | |
| private ProcessHandler. | |
| private ProcessHandler. | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv | ProcessCommand(List<String> command, String cwd, Map<String, String> environment, boolean redirectErrorStream, ProcessHandler.
|
| Modifier and Type | Method and Description |
|---|---|
| public static ProcessHandler. | create(List<String> cmd, String cwd, Map<String, String> environment, boolean redirectErrorStream, ProcessHandler.
Creates a ProcessCommand. |
| public List | |
| public String | |
| public Map | |
| public ProcessHandler. | |
| public ProcessHandler. | |
| public ProcessHandler. | |
| public boolean | isRedirectErrorStream()
Return whether the standard error output should be merged into standard output. |
| cmd | back to summary |
|---|---|
| private List<String> cmd | |
| cwd | back to summary |
|---|---|
| private String cwd | |
| environment | back to summary |
|---|---|
| private Map<String, String> environment | |
| errorRedirect | back to summary |
|---|---|
| private ProcessHandler. | |
| inputRedirect | back to summary |
|---|---|
| private ProcessHandler. | |
| outputRedirect | back to summary |
|---|---|
| private ProcessHandler. | |
| redirectErrorStream | back to summary |
|---|---|
| private boolean redirectErrorStream | |
| ProcessCommand | back to summary |
|---|---|
| pack-priv ProcessCommand(List<String> command, String cwd, Map<String, String> environment, boolean redirectErrorStream, ProcessHandler. | |
| create | back to summary |
|---|---|
| public static ProcessHandler. Creates a ProcessCommand. Not for direct use.
| |
| getCommand | back to summary |
|---|---|
| public List Returns the subprocess executable and arguments as an immutable list.
| |
| getDirectory | back to summary |
|---|---|
| public String getDirectory() Returns the subprocess working directory.
| |
| getEnvironment | back to summary |
|---|---|
| public Map Returns the subprocess environment as an immutable map.
| |
| getErrorRedirect | back to summary |
|---|---|
| public ProcessHandler. Returns the standard error output destination.
| |
| getInputRedirect | back to summary |
|---|---|
| public ProcessHandler. Returns the standard input source.
| |
| getOutputRedirect | back to summary |
|---|---|
| public ProcessHandler. Returns the standard output destination.
| |
| isRedirectErrorStream | back to summary |
|---|---|
| public boolean isRedirectErrorStream() Return whether the standard error output should be merged into standard output.
| |
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static enum |
| Modifier and Type | Field and Description |
|---|---|
| public static final ProcessHandler. | INHERIT
Indicates that subprocess I/O source or destination will be the same as those of the current process. |
| public static final ProcessHandler. | PIPE
Indicates that subprocess I/O will be connected to the current Java process using a pipe. |
| private final OutputStream | |
| private final ProcessHandler. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public static ProcessHandler. | |
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| public OutputStream | |
| public int | |
| public String |
| INHERIT | back to summary |
|---|---|
| public static final ProcessHandler. Indicates that subprocess I/O source or destination will be the same as those of the current process.
| |
| PIPE | back to summary |
|---|---|
| public static final ProcessHandler. Indicates that subprocess I/O will be connected to the current Java process using a pipe.
| |
| stream | back to summary |
|---|---|
| private final OutputStream stream | |
| type | back to summary |
|---|---|
| private final ProcessHandler. | |
| Redirect | back to summary |
|---|---|
| pack-priv Redirect(ProcessHandler. | |
| createRedirectToStream | back to summary |
|---|---|
| public static ProcessHandler. Creates a ProcessCommand. Not for direct use.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getOutputStream | back to summary |
|---|---|
| public OutputStream getOutputStream() Returns the output stream to redirect to.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Modifier and Type | Field and Description |
|---|---|
| public static final ProcessHandler. | INHERIT
The type of |
| public static final ProcessHandler. | PIPE
The type of |
| public static final ProcessHandler. | STREAM
The type of |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static ProcessHandler. | |
| public static ProcessHandler. |
| INHERIT | back to summary |
|---|---|
| public static final ProcessHandler. The type of | |
| PIPE | back to summary |
|---|---|
| public static final ProcessHandler. The type of | |
| STREAM | back to summary |
|---|---|
| public static final ProcessHandler. The type of | |
| Type | back to summary |
|---|---|
| private Type() | |
| valueOf | back to summary |
|---|---|
| public static ProcessHandler. | |
| values | back to summary |
|---|---|
| public static ProcessHandler. | |