public abstract class ForkProcessAction extends AbstractAction implements IfsParameters
Note: this class should be extended to implement the getCommand method, which returns the OS command that should be executed as an external process.
This class defines the following key:
timeout
- the timeout value in seconds. If this time elapses
and the process has not exited, the process will be
forcibly terminated by Process.destroy()
.
Modifier and Type | Field and Description |
---|---|
static String |
LOG_KEY
Boolean key telling whether to log the command and its standard output
or not.
|
protected boolean |
m_log |
static String |
TIMEOUT_KEY
Key mapping to the timeout value in seconds.
|
CONTINUE_ON_ERROR, m_defaultOptions, m_options
APPEND_LOG, DATABASE_TYPE, DATABASE_URL, DB_USER_NAME, DB_USER_PASSWORD, DOMAIN_TYPE, ENABLE_SSL_SUPPORT, FOR_SCHEMA_UPGRADE, IFS_DOMAIN_DISPLAY_NAME, IFS_DOMAIN_NAME, IFS_SCHEMA_NAME, IFS_SCHEMA_PASSWORD, IFS_SERVICE_NAME, IFS_USER_NAME, IFS_USER_PASSWORD, INCLUDE_PATH, INITIAL_CONTEXT_FACTORY, LDAP_URL_DAS_LOOKUP, LDAP_USER_NAME, LDAP_USER_PASSWORD, OUTPUT_FILE, PARAMETER_FILE, REGISTRY, SCHEMA_VERSION_KEY, SECURITY_PROTOCOL_NAME, SERVICE_CONFIGURATION_NAME
Constructor and Description |
---|
ForkProcessAction() |
Modifier and Type | Method and Description |
---|---|
void |
failed(Throwable t)
Does nothing.
|
protected abstract String |
getCommand()
Returns the OS command that should be invoked as an external process.
|
void |
perform()
Executes the process specified by the
getCommand method. |
protected void |
processDestroyed(StringWriter out,
StringWriter err)
Invoked when the external process was destroyed by this Action, due to a
timeout, an interrupt from another Thread, or other exceptional conditions.
|
protected void |
processFinished(int code,
StringWriter out,
StringWriter err)
Invoked when the external process has finished on its own.
|
void |
stop()
Forcibly stops the external process.
|
getDescription, getName, getValue, isContinueOnError, isPostgres, putValue, setDefaultOptions, setDescription, setName, setOptions
public static final String TIMEOUT_KEY
public static final String LOG_KEY
protected boolean m_log
public void perform() throws ActionFailedException
getCommand
method.
Waits until the process has finished and then calls the
processFinished
method. If the specified timeout period
has passed and the external process is still running, the external
process will be forcibly stopped, and the processFailed
method will be invoked.perform
in interface Action
ActionFailedException
- if the action could not be performed.public void failed(Throwable t)
protected abstract String getCommand()
protected void processFinished(int code, StringWriter out, StringWriter err) throws ActionFailedException
Note: subclasses may override this method; it has an empty implementation.
Note: subclasses may decide (based on the output from the process or the exit code) that the process did not finish successfully. In this case, the subclass may throw an ActionFailedException to notify that the action has in fact failed, even though the external process finished.
code
- the exit code returned by the Process.out
- a closed StringWriter with stdout output from the Process.err
- a closed StringWriter with stderr output form the Process.ActionFailedException
- if the process finished but was not
considered (by the action implementing this method) a
successful execution; thus the action has failed.protected void processDestroyed(StringWriter out, StringWriter err)
out
- a closed StringWriter with stdout output from the Process.err
- a closed StringWriter with stderr output form the Process.Copyright © 2023. All rights reserved.