|
org.netbeans.modules.extexecution/2 1.21.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.api.extexecution.ExternalProcessBuilder
public final class ExternalProcessBuilder
Utility class to make the external process creation easier.
Builder handle command, working directory, PATH variable and HTTP proxy.
This class is immutable.
call()| Constructor Summary | |
|---|---|
ExternalProcessBuilder(String executable)
Creates the new builder that will create the process by running given executable. |
|
| Method Summary | |
|---|---|
ExternalProcessBuilder |
addArgument(String argument)
Returns a builder with additional argument for the command. |
ExternalProcessBuilder |
addEnvironmentVariable(String name,
String value)
Returns a builder with additional environment variable for the command. |
Process |
call()
Creates the new Process based on the properties configured
in this builder. |
ExternalProcessBuilder |
prependPath(File path)
Returns a builder with additional path in PATH variable. |
ExternalProcessBuilder |
redirectErrorStream(boolean redirectErrorStream)
Returns a builder with configured error stream redirection. |
ExternalProcessBuilder |
workingDirectory(File workingDirectory)
Returns a builder with configured working directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExternalProcessBuilder(@NonNull
String executable)
executable - executable to run| Method Detail |
|---|
@NonNull
@CheckReturnValue
public ExternalProcessBuilder workingDirectory(@NonNull
File workingDirectory)
call() method on returned builder
will be executed with this directory as current working dir.
The default value is undefined. Note that in such case each process has
working directory corresponding to the value of user.dir
system property.
All other properties of the returned builder are inherited from
this.
workingDirectory - working directory
@NonNull @CheckReturnValue public ExternalProcessBuilder redirectErrorStream(boolean redirectErrorStream)
true process subsequently created by
the call() method on returned builder will redirect the error
stream to the standard output stream.
The default value is false.
All other properties of the returned builder are inherited from
this.
redirectErrorStream - if true error stream will be
redirected to standard output
@NonNull
@CheckReturnValue
public ExternalProcessBuilder prependPath(@NonNull
File path)
PATH variable.
In the group of paths added by this call the last added path will
be the first one in the PATH variable.
By default no additional paths are added to PATH variable.
All other properties of the returned builder are inherited from
this.
path - path to add to PATH variable
PATH variable
@NonNull
@CheckReturnValue
public ExternalProcessBuilder addArgument(@NonNull
String argument)
By default no additional arguments are passed to executable.
All other properties of the returned builder are inherited from
this.
If there is a need to parse arguments already provided as one big
string the method that can help is
Utilities.parseParameters(java.lang.String).
argument - command argument to add
@NonNull
@CheckReturnValue
public ExternalProcessBuilder addEnvironmentVariable(@NonNull
String name,
@NonNull
String value)
By default no additional environment variables are configured.
All other properties of the returned builder are inherited from
this.
name - name of the variablevalue - value of the variable
call()
@NonNull
public Process call()
throws IOException
Process based on the properties configured
in this builder. Created process will try to kill all its children on
call to Process.destroy().
Process is created by executing the executable with configured arguments.
If custom working directory is specified it is used otherwise value
of system property user.dir is used as working dir.
Environment variables are prepared in following way:
addEnvironmentVariable(java.lang.String, java.lang.String).
This rewrites system variables if conflict occurs.
PATH variable and append all paths added
by prependPath(java.io.File). The order of paths in PATH
variable is reversed to order of addition (the last added is the first
one in PATH). Original content of PATH follows
the added content.
http_proxy nor HTTP_PROXY
environment variable is set then HTTP proxy settings configured in the
IDE are stored as http_proxy environment variable
(the format of the value is http://username:password@host:port).
call in interface Callable<Process>Process based on the properties configured
in this builder
IOException - if the process could not be created
|
org.netbeans.modules.extexecution/2 1.21.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||