|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.concurrent.JVMBuilder
public class JVMBuilder
Creates Java subprocesses via an interface similar to that of ProcessBuilder. Each JVMBuilder
object is immutable, but can be used as a template for creating other JVMBuilder with altered parameters.
(Unlike ProcessBuilder, there is no implicit mutation via mutable maps returned by getters.) The following
parameters are supported:
javaCommand: Command, file, or directory used to invoke the JVM. If a directory is given,
the relative directories bin and ../bin are also searched for a java executable.
Default: the java.home property.jvmArgs: Arguments to pass to the java executable. These are passed before all
standard arguments supported here (e.g. "-classpath"). Default: empty.classPath: Class path to use in the JVM. Default: ReflectUtil.SYSTEM_CLASS_PATH.dir: Working directory of the new process. Default: System.getProperty("user.dir", "").properties: Java properties to define in the new JVM (passed to the java executable with
arguments of the form "-D<key>=<value>"); non-string entries are converted to strings via
toString. Default: empty.environment: System environment variables to define in the new JVM, or null signifying that
the current environment should be duplicated. Default: null.
| Field Summary | |
|---|---|
static JVMBuilder |
DEFAULT
|
| Constructor Summary | |
|---|---|
JVMBuilder(File dir)
|
|
JVMBuilder(Iterable<? extends File> classPath)
|
|
JVMBuilder(String javaCommand)
|
|
JVMBuilder(String javaCommand,
Iterable<? extends String> jvmArgs)
|
|
JVMBuilder(String javaCommand,
Iterable<? extends String> jvmArgs,
Iterable<? extends File> classPath,
File dir,
Map<? extends String,? extends String> properties,
Map<? extends String,? extends String> environment)
|
|
| Method Summary | |
|---|---|
JVMBuilder |
AddDefaultEnvironmentVar(String key,
String value)
If the current environment mappings do not contain key, produce a new JVMBuilder including the
mapping, in addition to those currently set. |
JVMBuilder |
addDefaultEnvironmentVars(Map<? extends String,? extends String> env)
Produce a JVMBuilder where, for each key in the given Map, if the environment variable is undefined in this JVMBuilder, it will map to the given value. |
JVMBuilder |
addDefaultProperties(Map<? extends String,? extends String> ps)
Produce a JVMBuilder where, for each key in the given Map, if the property is undefined in this JVMBuilder, it will map to the given value. |
JVMBuilder |
addDefaultProperties(Properties ps)
Produce a JVMBuilder where, for each key in the given Properties object (including those designated in the Properties object as defaults), if the property is undefined in this JVMBuilder, it will map to the given value. |
JVMBuilder |
addDefaultProperty(String key,
String value)
If the current JVM properties do not contain key, produce a new JVMBuilder including the
mapping, in addition to those currently set. |
JVMBuilder |
addEnvironmentVar(String key,
String value)
Produce a JVMBuilder including the given environment mapping, in addition to those currently set. |
JVMBuilder |
addProperty(String key,
String value)
Produce a JVMBuilder including the given JVM property mapping, in addition to those currently set. |
SizedIterable<File> |
classPath()
|
JVMBuilder |
classPath(File... classPath)
Due to overloading rules, this cannot be invoked via varargs with 0 arguments (the getter matches instead). |
JVMBuilder |
classPath(Iterable<? extends File> classPath)
|
JVMBuilder |
classPath(String classPath)
|
File |
directory()
|
JVMBuilder |
directory(File dir)
|
JVMBuilder |
directory(String dir)
|
Map<String,String> |
environment()
Get an immutable view of the environment, or null if the current process's environment is used. |
JVMBuilder |
environment(Map<? extends String,? extends String> env)
Produce a JVMBuilder setting the environment to the given mapping (may be null, meaning
the current process's environment will be duplicated. |
Map<String,String> |
environmentCopy()
Get a mutable copy of the environment. |
String |
javaCommand()
|
JVMBuilder |
javaCommand(File javaCommand)
|
JVMBuilder |
javaCommand(String javaCommand)
|
SizedIterable<String> |
jvmArguments()
|
JVMBuilder |
jvmArguments(Iterable<? extends String> jvmArgs)
|
JVMBuilder |
jvmArguments(String... jvmArgs)
Due to overloading rules, this cannot be invoked via varargs with 0 arguments (the getter matches instead). |
Map<String,String> |
properties()
Get an immutable view of the properties. |
JVMBuilder |
properties(Map<? extends String,? extends String> ps)
Produce a JVMBuilder setting the JVM properties to the given mapping. |
JVMBuilder |
properties(Properties ps)
Produce a JVMBuilder setting the JVM properties to the given mapping (including keys that appear only as defaults in the Properties object). |
Map<String,String> |
propertiesCopy()
Return a mutable copy of the properties. |
Process |
start(String mainClass,
Iterable<? extends String> mainParams)
Start a JVM process via Runtime.exec(String[], String[], File). |
Process |
start(String mainClass,
String... mainParams)
Start a JVM process via Runtime.exec(String[], String[], File). |
Process |
value(String mainClass,
Iterable<? extends String> mainParams)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final JVMBuilder DEFAULT
| Constructor Detail |
|---|
public JVMBuilder(String javaCommand)
public JVMBuilder(String javaCommand,
Iterable<? extends String> jvmArgs)
public JVMBuilder(Iterable<? extends File> classPath)
public JVMBuilder(File dir)
public JVMBuilder(String javaCommand,
Iterable<? extends String> jvmArgs,
Iterable<? extends File> classPath,
File dir,
Map<? extends String,? extends String> properties,
Map<? extends String,? extends String> environment)
| Method Detail |
|---|
public String javaCommand()
public JVMBuilder javaCommand(String javaCommand)
public JVMBuilder javaCommand(File javaCommand)
public SizedIterable<String> jvmArguments()
public JVMBuilder jvmArguments(Iterable<? extends String> jvmArgs)
public JVMBuilder jvmArguments(String... jvmArgs)
public SizedIterable<File> classPath()
public JVMBuilder classPath(Iterable<? extends File> classPath)
public JVMBuilder classPath(String classPath)
public JVMBuilder classPath(File... classPath)
public File directory()
public JVMBuilder directory(File dir)
public JVMBuilder directory(String dir)
public Map<String,String> properties()
public Map<String,String> propertiesCopy()
public JVMBuilder properties(Properties ps)
public JVMBuilder properties(Map<? extends String,? extends String> ps)
public JVMBuilder addProperty(String key,
String value)
public JVMBuilder addDefaultProperties(Properties ps)
public JVMBuilder addDefaultProperties(Map<? extends String,? extends String> ps)
public JVMBuilder addDefaultProperty(String key,
String value)
key, produce a new JVMBuilder including the
mapping, in addition to those currently set. Otherwise, return this.
public Map<String,String> environment()
null if the current process's environment is used.
public Map<String,String> environmentCopy()
null (meaning the the current
process's environment should be used), the result is a copy of System.getenv(). Changes
to the result do not affect this JVMBuilder, but a modified environment map can be used to create
another JVMBuilder.
public JVMBuilder environment(Map<? extends String,? extends String> env)
null, meaning
the current process's environment will be duplicated.
public JVMBuilder addEnvironmentVar(String key,
String value)
public JVMBuilder addDefaultEnvironmentVars(Map<? extends String,? extends String> env)
public JVMBuilder AddDefaultEnvironmentVar(String key,
String value)
key, produce a new JVMBuilder including the
mapping, in addition to those currently set. Otherwise, return this.
public Process start(String mainClass,
String... mainParams)
throws IOException
Runtime.exec(String[], String[], File). Varargs shortcut for
start(String, Iterable).
IOException
public Process start(String mainClass,
Iterable<? extends String> mainParams)
throws IOException
Runtime.exec(String[], String[], File). The array of command strings
contains, in order: the java command, the JVM args, "-classpath" followed by the class path, each
property using "-D<key>=<value>" notation, the name of the given main class, and the main
parameters.
IOException - Per Runtime.exec(String[], String[], File).
SecurityException - Per Runtime.exec(String[], String[], File).
public Process value(String mainClass,
Iterable<? extends String> mainParams)
value in interface Lambda2<String,Iterable<? extends String>,Process>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||