Class SpincastProcessUtilsDefault
- All Implemented Interfaces:
 SpincastProcessUtils
- 
Field Summary
Fields - 
Constructor Summary
ConstructorsConstructorDescriptionSpincastProcessUtilsDefault(SpincastConfig spincastConfig, SpincastUtils spincastUtils, TemplatingEngine templatingEngine)  - 
Method Summary
Modifier and TypeMethodDescriptionprotected ProcessBuilderConfigure input/output streamsvoidexecuteAsync(ProcessExecutionHandler handler, long timeoutAmount, TimeUnit timeoutUnit, String... cmdArgs) Execute an external program asynchronously.voidexecuteAsync(ProcessExecutionHandler handler, long timeoutAmount, TimeUnit timeoutUnit, List<String> cmdArgs) Execute an external program asynchronously.voidexecuteAsync(ProcessExecutionHandler handler, String... cmdArgs) Execute an external program asynchronously.voidexecuteAsync(ProcessExecutionHandler handler, List<String> cmdArgs) Execute an external program asynchronously.executeGoalOnExternalMavenProject(ResourceInfo projectRootInfo, MavenProjectGoal mavenGoal) Execute the specifiedgoalon an external Maven project.executeGoalOnExternalMavenProject(ResourceInfo projectRootInfo, MavenProjectGoal mavenGoal, Map<String, Object> pomParams) Execute the specifiedgoalon an external Maven project.executeSync(long timeoutAmount, TimeUnit timeoutUnit, String... cmdArgs) Execute an external program synchronously.executeSync(long timeoutAmount, TimeUnit timeoutUnit, List<String> cmdArgs) Execute an external program synchronously.executeSync(long timeoutAmount, TimeUnit timeoutUnit, ExecutionOutputStrategy executionOutputStrategy, String... cmdArgs) Execute an external program synchronously.executeSync(long timeoutAmount, TimeUnit timeoutUnit, ExecutionOutputStrategy executionOutputStrategy, List<String> cmdArgs) Execute an external program synchronously.protected SpincastConfigprotected SpincastUtilsprotected TemplatingEngineprotected voidkillProcess(Process process) protected voidstartSystemErrReader(Process process, ProcessExecutionHandler handler) protected voidstartSystemOutReader(Process process, ProcessExecutionHandler handler) protected voidwaitForStreamsToBeEmpty(Thread systemOutReaderThread, Thread systemErrReaderThread)  
- 
Field Details
- 
logger
protected static final org.slf4j.Logger logger 
 - 
 - 
Constructor Details
- 
SpincastProcessUtilsDefault
@Inject public SpincastProcessUtilsDefault(SpincastConfig spincastConfig, SpincastUtils spincastUtils, TemplatingEngine templatingEngine)  
 - 
 - 
Method Details
- 
getSpincastConfig
 - 
getSpincastUtils
 - 
getTemplatingEngine
 - 
executeGoalOnExternalMavenProject
public File executeGoalOnExternalMavenProject(ResourceInfo projectRootInfo, MavenProjectGoal mavenGoal) Description copied from interface:SpincastProcessUtilsExecute the specifiedgoalon an external Maven project.If the project is located on the classpath, it first copies it to the file system (in a temp folder).
- Specified by:
 executeGoalOnExternalMavenProjectin interfaceSpincastProcessUtils- Returns:
 - the root directory of the project. This will be the same as the specified path if on the file system, or will be the created temp directory where the project has been copied (from the classpath) otherwise.
 
 - 
executeGoalOnExternalMavenProject
public File executeGoalOnExternalMavenProject(ResourceInfo projectRootInfo, MavenProjectGoal mavenGoal, Map<String, Object> pomParams) Description copied from interface:SpincastProcessUtilsExecute the specifiedgoalon an external Maven project.If the project is located on the classpath, it first copies it to the file system (in a temp folder).
- Specified by:
 executeGoalOnExternalMavenProjectin interfaceSpincastProcessUtilspomParams- Before executing thegoal, those parameters are used to replace placeholders in the project'spom.xmlusing Spincast'sTemplatingEngine.- Returns:
 - the root directory of the project. This will be the same as the specified path if on the file system, or will be the created temp directory where the project has been copied (from the classpath) otherwise.
 
 - 
executeAsync
Description copied from interface:SpincastProcessUtilsExecute an external program asynchronously.The method will only return when the process is actually created or if an exception occured when trying to do so.
If this creates a process that is not made to exit automatically (for example it starts an HTTP server), you must kill the process by yourself!:
ProcessExecutionHandlerDefault handler = new ProcessExecutionHandlerDefault(); { // override some methods... }; getSpincastProcessUtils().executeAsync(handler, "java", "-jar", jarFile.getAbsolutePath()); try { //... } finally { handler.killProcess(); }- Specified by:
 executeAsyncin interfaceSpincastProcessUtils- Parameters:
 handler- to get information from the created process and to be able to kill it.
 - 
executeAsync
public void executeAsync(ProcessExecutionHandler handler, long timeoutAmount, TimeUnit timeoutUnit, String... cmdArgs) Description copied from interface:SpincastProcessUtilsExecute an external program asynchronously.The method will only return when the process is actually created or if an exception occured when trying to do so.
If this creates a process that is not made to exit automatically (for example it starts an HTTP server), you must kill the process by yourself!:
ProcessExecutionHandlerDefault handler = new ProcessExecutionHandlerDefault(); { // override some methods... };(); getSpincastProcessUtils().executeAsync(handler, "java", "-jar", jarFile.getAbsolutePath()); try { //... } finally { handler.killProcess(); }- Specified by:
 executeAsyncin interfaceSpincastProcessUtils- Parameters:
 handler- to get information from the created process and to be able to kill it.timeoutAmount- the amount of time the external program is allowed to run before a timeout occurs. When the timeout occurs:- The process is killed
 - 
 
onTimeoutException()is called 
onExit()will not be called if a timeout occurs!timeoutUnit- the timeout unit.
 - 
executeAsync
Description copied from interface:SpincastProcessUtilsExecute an external program asynchronously.The method will only return when the process is actually created or if an exception occured when trying to do so.
If this creates a process that is not made to exit automatically (for example it starts an HTTP server), you must kill the process by yourself!:
ProcessExecutionHandlerDefault handler = new ProcessExecutionHandlerDefault(); { // override some methods... }; getSpincastProcessUtils().executeAsync(handler, "java", "-jar", jarFile.getAbsolutePath()); try { //... } finally { handler.killProcess(); }- Specified by:
 executeAsyncin interfaceSpincastProcessUtils- Parameters:
 handler- to get information from the created process and to be able to kill it.
 - 
executeAsync
public void executeAsync(ProcessExecutionHandler handler, long timeoutAmount, TimeUnit timeoutUnit, List<String> cmdArgs) Description copied from interface:SpincastProcessUtilsExecute an external program asynchronously.The method will only return when the process is actually created or if an exception occured when trying to do so.
If this creates a process that is not made to exit automatically (for example it starts an HTTP server), you must kill the process by yourself!:
ProcessExecutionHandlerDefault handler = new ProcessExecutionHandlerDefault(); { // override some methods... }; getSpincastProcessUtils().executeAsync(handler, "java", "-jar", jarFile.getAbsolutePath()); try { //... } finally { handler.killProcess(); }- Specified by:
 executeAsyncin interfaceSpincastProcessUtils- Parameters:
 handler- to get information from the created process and to be able to kill it.timeoutAmount- the amount of time the external program is allowed to run before a timeout occurs. When the timeout occurs:- The process is killed
 - 
 
onTimeoutException()is called 
onExit()will not be called if a timeout occurs!timeoutUnit- the timeout unit.
 - 
killProcess
 - 
configureStreams
Configure input/output streams - 
startSystemOutReader
 - 
startSystemErrReader
 - 
waitForStreamsToBeEmpty
 - 
executeSync
public SyncExecutionResult executeSync(long timeoutAmount, TimeUnit timeoutUnit, String... cmdArgs) throws LaunchException, TimeoutException Description copied from interface:SpincastProcessUtilsExecute an external program synchronously.By default
SYSTEMis used as the output strategy so it is printed toSystem.outandSystem.err.- Specified by:
 executeSyncin interfaceSpincastProcessUtils- Parameters:
 timeoutAmount- the amount of time the external program is allowed to run before a timeout occurs. When the timeout occurs:- The process is killed
 - 
 A 
TimeoutExceptionexception is thrown. 
timeoutUnit- the timeout unit.- Returns:
 - an object contaning the information about the execution of the program.
 - Throws:
 LaunchException- if the program can't be launched properly.TimeoutException- if the specified timeout is exceeded.
 - 
executeSync
public SyncExecutionResult executeSync(long timeoutAmount, TimeUnit timeoutUnit, List<String> cmdArgs) throws LaunchException, TimeoutException Description copied from interface:SpincastProcessUtilsExecute an external program synchronously.By default
SYSTEMis used as the output strategy so it is printed toSystem.outandSystem.err.- Specified by:
 executeSyncin interfaceSpincastProcessUtils- Parameters:
 timeoutAmount- the amount of time the external program is allowed to run before a timeout occurs. When the timeout occurs:- The process is killed
 - 
 A 
TimeoutExceptionexception is thrown. 
timeoutUnit- the timeout unit.- Returns:
 - an object contaning the information about the execution of the program.
 - Throws:
 LaunchException- if the program can't be launched properly.TimeoutException- if the specified timeout is exceeded.
 - 
executeSync
public SyncExecutionResult executeSync(long timeoutAmount, TimeUnit timeoutUnit, ExecutionOutputStrategy executionOutputStrategy, String... cmdArgs) throws LaunchException, TimeoutException Description copied from interface:SpincastProcessUtilsExecute an external program synchronously.By default
SYSTEMis used as the output strategy so it is printed toSystem.outandSystem.err.- Specified by:
 executeSyncin interfaceSpincastProcessUtils- Parameters:
 timeoutAmount- the amount of time the external program is allowed to run before a timeout occurs. When the timeout occurs:- The process is killed.
 - 
 A 
TimeoutExceptionexception is thrown. 
timeoutUnit- the timeout unit.executionOutputStrategy- what should be done with the output of the executed program?- Returns:
 - an object contaning the information about the execution of the program.
 - Throws:
 LaunchException- if the program can't be launched properly.TimeoutException- if the specified timeout is exceeded.
 - 
executeSync
public SyncExecutionResult executeSync(long timeoutAmount, TimeUnit timeoutUnit, ExecutionOutputStrategy executionOutputStrategy, List<String> cmdArgs) throws LaunchException, TimeoutException Description copied from interface:SpincastProcessUtilsExecute an external program synchronously.By default
SYSTEMis used as the output strategy so it is printed toSystem.outandSystem.err.- Specified by:
 executeSyncin interfaceSpincastProcessUtils- Parameters:
 timeoutAmount- the amount of time the external program is allowed to run before a timeout occurs. When the timeout occurs:- The process is killed.
 - 
 A 
TimeoutExceptionexception is thrown. 
timeoutUnit- the timeout unit.executionOutputStrategy- what should be done with the output of the executed program?- Returns:
 - an object contaning the information about the execution of the program.
 - Throws:
 LaunchException- if the program can't be launched properly.TimeoutException- if the specified timeout is exceeded.
 
 -