public abstract class JavaHook extends java.lang.Object implements HookConfig
If the engine is being launched manually or via a batch file or script then the following Java System property should be set on the Java command line:
testpath is the file path to the test configuration INI file,
projectpath is the file path to the project configuration INI file,
driverpath is the file path to the SAFS driver configuration INI file.
Concrete subclasses will have to provide their specific flavors of subclasses for:
Concrete subclasses need to consider overriding the following methods if they need to alter the default behavior:
Modifier and Type | Field and Description |
---|---|
protected TestRecordHelper |
data
The TestRecordHelper the hook will use for handling TestRecordData.
|
protected static int |
DEBUG_MESSAGE
Convenience for local referencing instead of referencing AbstractLogFacility.
|
protected GetText |
errorText
"failedSAFSTextResourceBundle" -- our default source of error messages
|
protected static int |
FAILED_MESSAGE
Log MessageType for local referencing.
|
protected static int |
FAILED_OK_MESSAGE
Log MessageType for local referencing.
|
protected static java.lang.String |
GENERIC_ERROR
"generic_error"
|
protected static int |
GENERIC_MESSAGE
Convenience for local referencing instead of referencing AbstractLogFacility.
|
protected STAFHelper |
helper
The STAFHelper used to interact with STAF.
|
protected HookConfig |
hookconfig
Used to get settings from ConfigureInterface.
|
protected LogUtilities |
log
The LogUtilities the hook will use for logging.
|
protected static int |
PASSED_MESSAGE
Log MessageType for local referencing.
|
static java.lang.String |
PAUSE_EXECUTION
"PAUSE"
|
static java.lang.String |
PAUSE_SWITCH_OFF
"OFF" for SAFSVARS variable 'SAFS_DRIVER_CONTROL_POF'/'SAFS_DRIVER_CONTROL_POW'
|
static java.lang.String |
PAUSE_SWITCH_ON
"ON" for SAFSVARS variable 'SAFS_DRIVER_CONTROL_POF'/'SAFS_DRIVER_CONTROL_POW'
|
protected java.lang.String |
process_name
The name of the process this hook supports.
|
protected ProcessRequest |
processor
The ProcessRequest object the hook will use for handling input records.
|
static long |
REQUEST_PROCEED_TESTING
0
Proceed with normal testing
|
static long |
REQUEST_USER_STOPPED_SCRIPT_REQUEST
-1
The user has requested to STOP or ABORT execution of this engine.
|
static java.lang.String |
RUNNING_EXECUTION
"RUNNING"
|
protected java.lang.String |
semaphore_name
The root name used in STAF Semaphore EVENT communication.
|
static java.lang.String |
SHUTDOWN_RECORD
"SHUTDOWN_HOOK"
|
protected static java.lang.String |
STAF_ERROR
"staf_error"
|
static java.lang.String |
STEP_EXECUTION
"STEP"
|
static java.lang.String |
STEP_RETRY_EXECUTION
"STEP_RETRY"
|
static java.lang.String |
STEPPING_EXECUTION
"STEPPING"
|
static java.lang.String |
STEPPING_RETRY_EXECUTION
"STEPPING_RETRY"
|
protected java.lang.String |
trd_name
Root Name of TestRecordData store in SAFSVARS.
|
protected DDGUIUtilities |
utils
The DDGUIUtilities the hook will use for handling components.
|
protected static int |
WARNING_MESSAGE
Log MessageType for local referencing.
|
protected static int |
WARNING_OK_MESSAGE
Log MessageType for local referencing.
|
Constructor and Description |
---|
JavaHook()
Empty Constructor.
|
JavaHook(java.lang.String process_name)
Minimal initialization constructor.
|
JavaHook(java.lang.String process_name,
LogUtilities logs)
Minimal initialization constructor.
|
JavaHook(java.lang.String process_name,
java.lang.String trd_name)
Minimal initialization constructor.
|
JavaHook(java.lang.String process_name,
java.lang.String trd_name,
LogUtilities logs)
Standard initialization constructor.
|
JavaHook(java.lang.String process_name,
java.lang.String trd_name,
LogUtilities logs,
TestRecordHelper trd_data,
DDGUIUtilities gui_utils,
ProcessRequest aprocessor)
Advanced Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
allowSystemExit()
Evaluate if the runtime hook should exit with System.exit(0).
|
void |
checkConfiguration()
Call
initConfigPaths() to initialize the ConfigureInterface instance.Call instantiateHookConfig() to initialize the HookConfig instance.Call HookConfig.checkConfiguration() to check configuration settings for Hook. |
protected boolean |
driverShutdownRequest() |
protected long |
evaluateRuntimeException(java.lang.RuntimeException ex)
Evaluate if the runtime hook should shutdown, proceed, or some other action
following the receipt of a RuntimeException.
|
abstract DDGUIUtilities |
getGUIUtilities()
Retrieve the DDGUIUtilities used by the subclass.
|
STAFHelper |
getHelper() |
abstract LogUtilities |
getLogUtilities()
Retrieve the LogUtilities used by the subclass.
|
java.lang.String |
getProcessName() |
abstract ProcessRequest |
getRequestProcessor()
Retrieve the ProcessRequest instance used by the subclass.
|
java.lang.String |
getSemaphoreName() |
abstract TestRecordHelper |
getTRDData()
Retrieve the TestRecordHelper used by the subclass.
|
java.lang.String |
getTRDName() |
protected boolean |
hook_shutdown()
Perform final hook shutdown activities before the check for allowSystemExit.
|
protected void |
initConfigPaths()
Initialize access to chained ConfigurationInterface data.
|
protected void |
instantiateHookConfig()
Instantiate the HookConfig, used to get settings from ConfigureInterface.
|
void |
setGUIUtilities(DDGUIUtilities gui_utils) |
void |
setHelper(java.lang.Object processhelper)
Set our STAFHelper to be the one provided.
|
void |
setLogUtilities(LogUtilities lu) |
protected void |
setProcessName(java.lang.String process_name)
Set the process name for this hook for an instance created from an empty constructor.
|
void |
setRequestProcessor(ProcessRequest aprocessor) |
protected void |
setSemaphoreName(java.lang.String semname) |
void |
setTRDData(TestRecordHelper trd_data) |
void |
setTRDName(java.lang.String trdname) |
void |
start()
Insert this SAFS Engine hook into the STAF system.
|
public static final java.lang.String SHUTDOWN_RECORD
public static final java.lang.String PAUSE_EXECUTION
public static final java.lang.String STEP_EXECUTION
public static final java.lang.String STEPPING_EXECUTION
public static final java.lang.String RUNNING_EXECUTION
public static final java.lang.String STEP_RETRY_EXECUTION
public static final java.lang.String STEPPING_RETRY_EXECUTION
public static final java.lang.String PAUSE_SWITCH_ON
public static final java.lang.String PAUSE_SWITCH_OFF
protected static final int DEBUG_MESSAGE
protected static final int GENERIC_MESSAGE
protected static final int FAILED_MESSAGE
protected static final int FAILED_OK_MESSAGE
protected static final int PASSED_MESSAGE
protected static final int WARNING_MESSAGE
protected static final int WARNING_OK_MESSAGE
public static final long REQUEST_USER_STOPPED_SCRIPT_REQUEST
public static final long REQUEST_PROCEED_TESTING
protected HookConfig hookconfig
instantiateHookConfig()
protected java.lang.String process_name
protected java.lang.String semaphore_name
protected java.lang.String trd_name
protected LogUtilities log
protected STAFHelper helper
protected TestRecordHelper data
protected DDGUIUtilities utils
protected ProcessRequest processor
protected GetText errorText
protected static final java.lang.String GENERIC_ERROR
protected static final java.lang.String STAF_ERROR
public JavaHook()
public JavaHook(java.lang.String process_name)
process_name
- -- The process name associated with STAF for this hook.public JavaHook(java.lang.String process_name, LogUtilities logs)
process_name
- -- The process name associated with STAF for this hook.logs
- -- The LogUtilities to use for STAF logging.public JavaHook(java.lang.String process_name, java.lang.String trd_name)
process_name
- -- The process name associated with STAF for this hook.trd_name
- -- The root name for specific TestRecordData to reference in
STAF. This should typically be STAFHelper.SAFS_HOOK_TRD
which is used by default.public JavaHook(java.lang.String process_name, java.lang.String trd_name, LogUtilities logs)
process_name
- -- The process name associated with STAF for this hook.trd_name
- -- The root name for specific TestRecordData to reference in
STAF. This should typically be STAFHelper.SAFS_HOOK_TRD
which is used by default.logs
- -- The LogUtilities to use for STAF logging.public JavaHook(java.lang.String process_name, java.lang.String trd_name, LogUtilities logs, TestRecordHelper trd_data, DDGUIUtilities gui_utils, ProcessRequest aprocessor)
The hook will use the global TestRecordData storage with the root TestRecordData name given. The LogUtilities provided will be used for all logging.
process_name
- -- The process name associated with STAF for this hook.trd_name
- -- The root name for specific TestRecordData to reference in
SAFSVARS. This should typically be STAFHelper.SAFS_HOOK_TRD
which is used by default.logs
- -- The LogUtilities to use for STAF logging.trd_data
- -- TestRecordHelper to hold TestRecordData.gui_utils
- -- DDGUIUtilities the hook will use for handling components.aprocessor
- -- ProcessRequest object the hook will use for routing records.public java.lang.String getProcessName()
protected void setProcessName(java.lang.String process_name)
protected void setSemaphoreName(java.lang.String semname)
public java.lang.String getSemaphoreName()
public java.lang.String getTRDName()
public void setTRDName(java.lang.String trdname)
public abstract LogUtilities getLogUtilities()
public void setLogUtilities(LogUtilities lu)
public STAFHelper getHelper()
public void setHelper(java.lang.Object processhelper)
The user can initialize both the process name and the STAFHelper by calling this routine with a valid process name String or STAFHelper.
If the current instance already has a defined process name, then any process name provided here is ignored and the STAFHelper is initialized with the existing value.
If the user provides a valid STAFHelper; then the process_name will be set to the name used to create the STAFHelper.
NOTE: This will automatically reset the semaphore_name to be the same as the process_name. This is the default mode of operation and should be OK for most applications. However, if the semaphore_name is to be different, then you must also call setSemaphoreName after this call.
processhelper
- -- Object: String process name used to create/retrieve a
STAFHelper; or an already instanced STAFHelper object.java.lang.NullPointerException
- (with message) -- if null is provided.public abstract TestRecordHelper getTRDData()
public void setTRDData(TestRecordHelper trd_data)
public abstract DDGUIUtilities getGUIUtilities()
public void setGUIUtilities(DDGUIUtilities gui_utils)
public abstract ProcessRequest getRequestProcessor()
public void setRequestProcessor(ProcessRequest aprocessor)
protected void initConfigPaths()
protected void instantiateHookConfig()
initConfigPaths()
. initConfigPaths()
public void checkConfiguration()
initConfigPaths()
to initialize the ConfigureInterface instance.instantiateHookConfig()
to initialize the HookConfig instance.HookConfig.checkConfiguration()
to check configuration settings for Hook.checkConfiguration
in interface HookConfig
public void start()
protected long evaluateRuntimeException(java.lang.RuntimeException ex)
By default, this implementation will proceed with testing. Subclasses may wish to override this function to evaluate the RuntimeException and react accordingly.
protected boolean driverShutdownRequest()
protected boolean hook_shutdown()
This default implementation simply unregisters our STAFProcessHelper if it is not null. Subclasses may wish to provide additional functionality before calling super.hook_shutdown().
allowSystemExit()
protected boolean allowSystemExit()
The default implementation will return true allowing the System.exit(0). Subclasses may wish to override this function to prevent the execution of System.exit(0) when this is not appropriate.
Copyright © SAS Institute. All Rights Reserved.