Add overloaded launch(..) method to ProcessExecutor accepting a Java CLASSPATH, Class type with the main method to run and an array of String arguments passed to the forked Java program.
This commit is contained in:
@@ -52,60 +52,80 @@ public abstract class ProcessExecutor {
|
|||||||
protected static final String SPRING_GEMFIRE_SYSTEM_PROPERTY_PREFIX = "spring.gemfire.";
|
protected static final String SPRING_GEMFIRE_SYSTEM_PROPERTY_PREFIX = "spring.gemfire.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch (run) the given Java {@link Class} (program) passing in the given array of {@link Object arguments}
|
* Launch (run/execute) the given Java {@link Class} (program) passing in the given array of {@link String arguments}
|
||||||
* to the program.
|
* to the program at runtime.
|
||||||
*
|
*
|
||||||
* @param type Java {@link Class} (program) to launch in a forked JVM process.
|
* @param type Java {@link Class} (program) to launch in a forked JVM process.
|
||||||
* @param args array of {@link Object} arguments to the pass to the Java program.
|
* @param arguments array of {@link String} arguments to the pass to the Java program.
|
||||||
* @return a {@link ProcessWrapper} wrapping the Java {@link Process} representing the forked JVM.
|
* @return a {@link ProcessWrapper} wrapping the Java {@link Process} representing the forked JVM process.
|
||||||
* @throws IOException if the Java program could not be lauched (run).
|
* @throws IOException if the Java program could not be launched (run).
|
||||||
* @see org.springframework.data.gemfire.tests.process.ProcessWrapper
|
* @see org.springframework.data.gemfire.tests.process.ProcessWrapper
|
||||||
* @see #launch(File, Class, String...)
|
* @see #launch(File, Class, String...)
|
||||||
* @see java.lang.Class
|
* @see java.lang.Class
|
||||||
*/
|
*/
|
||||||
public static ProcessWrapper launch(Class<?> type, String... args) throws IOException {
|
public static ProcessWrapper launch(Class<?> type, String... arguments) throws IOException {
|
||||||
return launch(FileSystemUtils.WORKING_DIRECTORY, type, args);
|
return launch(FileSystemUtils.WORKING_DIRECTORY, type, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch (run) the given Java {@link Class} (program) in the specified {@link File working directory} and pass in
|
* Launch (run/execute) the given Java {@link Class} (program) in the specified {@link File working directory}
|
||||||
* the given array of {@link Object arguments} to the program.
|
* and pass in the given array of {@link String arguments} to the program at runtime.
|
||||||
*
|
*
|
||||||
* @param type Java {@link Class} (program) to launch in a forked JVM process.
|
* @param type Java {@link Class} (program) to launch in a forked JVM process.
|
||||||
* @param workingDirectory {@link File} referring to the working directory of the forked JVM process.
|
* @param workingDirectory {@link File} referring to the working directory of the forked JVM process.
|
||||||
* @param args array of {@link Object} arguments to the pass to the Java program.
|
* @param arguments array of {@link String} arguments to the pass to the Java program.
|
||||||
* @return a {@link ProcessWrapper} wrapping the Java {@link Process} representing the forked JVM.
|
* @return a {@link ProcessWrapper} wrapping the Java {@link Process} representing the forked JVM process.
|
||||||
* @throws IOException if the Java program could not be lauched (run).
|
* @throws IOException if the Java program could not be launched (run).
|
||||||
* @see org.springframework.data.gemfire.tests.process.ProcessWrapper
|
* @see org.springframework.data.gemfire.tests.process.ProcessWrapper
|
||||||
* @see #launch(File, String, Class, String...)
|
* @see #launch(File, String, Class, String...)
|
||||||
* @see java.lang.Class
|
* @see java.lang.Class
|
||||||
* @see java.io.File
|
* @see java.io.File
|
||||||
*/
|
*/
|
||||||
public static ProcessWrapper launch(File workingDirectory, Class<?> type, String... args) throws IOException {
|
public static ProcessWrapper launch(File workingDirectory, Class<?> type, String... arguments) throws IOException {
|
||||||
return launch(workingDirectory, JAVA_CLASSPATH, type, args);
|
return launch(workingDirectory, JAVA_CLASSPATH, type, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch (run) the given Java {@link Class} (program) in the specified {@link File working directory}, using the
|
* Launch (run/execute) the given Java {@link Class} (program) with the specified {@link String JVM classpath}
|
||||||
* given {@link String CLASSPATH} and pass in the given array of {@link Object arguments} to the program.
|
* in the {@link File current working directory} and pass in the given array of {@link Object arguments}
|
||||||
|
* to the program at runtime.
|
||||||
*
|
*
|
||||||
* @param type Java {@link Class} (program) to launch in a forked JVM process.
|
* @param type Java {@link Class} (program) to launch in a forked JVM process.
|
||||||
* @param workingDirectory {@link File} referring to the working directory of the forked JVM process.
|
|
||||||
* @param classpath {@link String} containing the classpath elements to pass to the JVM to run the Java program.
|
* @param classpath {@link String} containing the classpath elements to pass to the JVM to run the Java program.
|
||||||
* @param args array of {@link Object} arguments to the pass to the Java program.
|
* @param arguments array of {@link String} arguments to the pass to the Java program.
|
||||||
* @return a {@link ProcessWrapper} wrapping the Java {@link Process} representing the forked JVM.
|
* @return a {@link ProcessWrapper} wrapping the Java {@link Process} representing the forked JVM process.
|
||||||
* @throws IOException if the Java program could not be lauched (run).
|
* @throws IOException if the Java program could not be launched (run).
|
||||||
|
* @see org.springframework.data.gemfire.tests.process.ProcessWrapper
|
||||||
|
* @see #launch(File, String, Class, String...)
|
||||||
|
* @see java.lang.Class
|
||||||
|
* @see java.io.File
|
||||||
|
*/
|
||||||
|
public static ProcessWrapper launch(String classpath, Class<?> type, String... arguments) throws IOException {
|
||||||
|
return launch(FileSystemUtils.WORKING_DIRECTORY, classpath, type, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch (run/execute) the given Java {@link Class} (program) in the specified {@link File working directory},
|
||||||
|
* using the given {@link String Java CLASSPATH} and pass in the given array of {@link String arguments}
|
||||||
|
* to the program at runtime.
|
||||||
|
*
|
||||||
|
* @param type Java {@link Class} (program) to launch in a forked JVM process.
|
||||||
|
* @param workingDirectory {@link File} referring to the {@literal working directory} of the forked JVM process.
|
||||||
|
* @param classpath {@link String} containing the classpath elements to pass to the JVM to run the Java program.
|
||||||
|
* @param arguments array of {@link String} arguments to the pass to the Java program.
|
||||||
|
* @return a {@link ProcessWrapper} wrapping the Java {@link Process} representing the forked JVM process.
|
||||||
|
* @throws IOException if the Java program could not be launched (run).
|
||||||
* @see org.springframework.data.gemfire.tests.process.ProcessWrapper
|
* @see org.springframework.data.gemfire.tests.process.ProcessWrapper
|
||||||
* @see #buildCommand(String, Class, String...)
|
* @see #buildCommand(String, Class, String...)
|
||||||
* @see java.lang.ProcessBuilder
|
* @see java.lang.ProcessBuilder
|
||||||
* @see java.lang.Class
|
* @see java.lang.Class
|
||||||
* @see java.io.File
|
* @see java.io.File
|
||||||
*/
|
*/
|
||||||
public static ProcessWrapper launch(File workingDirectory, String classpath, Class<?> type, String... args)
|
public static ProcessWrapper launch(File workingDirectory, String classpath, Class<?> type, String... arguments)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder()
|
ProcessBuilder processBuilder = new ProcessBuilder()
|
||||||
.command(buildCommand(classpath, type, args))
|
.command(buildCommand(classpath, type, arguments))
|
||||||
.directory(validateDirectory(workingDirectory))
|
.directory(validateDirectory(workingDirectory))
|
||||||
.redirectErrorStream(true);
|
.redirectErrorStream(true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user