Class ProcessExecutionHandlerDefault
java.lang.Object
org.spincast.plugins.processutils.ProcessExecutionHandlerDefault
- All Implemented Interfaces:
HttpServerProcessHandlerExecutionHandler
,ProcessExecutionHandler
- Direct Known Subclasses:
ProcessExecutionHandlerSync
public class ProcessExecutionHandlerDefault
extends Object
implements HttpServerProcessHandlerExecutionHandler
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Process
protected ProcessKiller
Can benull
if the process was not created.protected boolean
boolean
Returnstrue
if the process is alive;void
Kill the process.void
onEnd()
Always called at the end, whether the process exited or an exception occured.void
onExit
(int exitCode) Called when the execution process exitsvoid
Called if an exception occured during the launch of the program.void
onSystemErr
(String line) Called when a line is written to the standard errors by the created process.void
onSystemOut
(String line) Called when a line is written to the standard output by the created process.void
Called if the execution of the program exceeds the specified timeout.void
void
setProcessAndProcessKiller
(Process process, ProcessKiller processKiller) Internal use.void
waitForPortOpen
(String host, int port, int nbrTry, int sleepMilliseconds) Wait for the specified host:port to be connectable.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
ProcessExecutionHandlerDefault
public ProcessExecutionHandlerDefault()
-
-
Method Details
-
getProcess
-
getProcessKiller
Can benull
if the process was not created. -
isProcessAlive
public boolean isProcessAlive()Description copied from interface:ProcessExecutionHandler
Returnstrue
if the process is alive;- Specified by:
isProcessAlive
in interfaceProcessExecutionHandler
-
setProcessAndProcessKiller
Description copied from interface:ProcessExecutionHandler
Internal use.Will be called automatically when the process is created.
- Specified by:
setProcessAndProcessKiller
in interfaceProcessExecutionHandler
-
isKillingRequested
protected boolean isKillingRequested() -
setKillingRequested
public void setKillingRequested() -
waitForPortOpen
public void waitForPortOpen(String host, int port, int nbrTry, int sleepMilliseconds) throws PortNotOpenException Description copied from interface:HttpServerProcessHandlerExecutionHandler
Wait for the specified host:port to be connectable.- Specified by:
waitForPortOpen
in interfaceHttpServerProcessHandlerExecutionHandler
- Throws:
PortNotOpenException
-
killProcess
public void killProcess()Description copied from interface:ProcessExecutionHandler
Kill the process.- Specified by:
killProcess
in interfaceProcessExecutionHandler
-
onExit
public void onExit(int exitCode) Called when the execution process exits- Specified by:
onExit
in interfaceProcessExecutionHandler
-
onLaunchException
Description copied from interface:ProcessExecutionHandler
Called if an exception occured during the launch of the program.- Specified by:
onLaunchException
in interfaceProcessExecutionHandler
-
onEnd
public void onEnd()Description copied from interface:ProcessExecutionHandler
Always called at the end, whether the process exited or an exception occured.- Specified by:
onEnd
in interfaceProcessExecutionHandler
-
onTimeoutException
public void onTimeoutException()Description copied from interface:ProcessExecutionHandler
Called if the execution of the program exceeds the specified timeout.- Specified by:
onTimeoutException
in interfaceProcessExecutionHandler
-
onSystemOut
Description copied from interface:ProcessExecutionHandler
Called when a line is written to the standard output by the created process.- Specified by:
onSystemOut
in interfaceProcessExecutionHandler
-
onSystemErr
Description copied from interface:ProcessExecutionHandler
Called when a line is written to the standard errors by the created process.- Specified by:
onSystemErr
in interfaceProcessExecutionHandler
-