|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.safs.jvmagent.SEMEventMonitor
public class SEMEventMonitor
Monitors the STAF SEM service for a specific event and executes an action upon receiving the event trigger. The monitor will only perform this function if isTriggerEnabled returns true during initialization.
This superclass is a full implementation. Subclasses will generally override the setEventCriteria, isTriggerEnabled, and performAction functions to provide different capabilities.
This type of mechanism is needed because one of the intended applications of subclasses is to be injected in each JVM via the Java Extensions mechanism often used for assistive technologies. While the object will be injected into every JVM, we only want the object to respond and act in specific JVM instances, not all JVM instances.
This superclass will list all the key=value pairs in the JVM System.properties when it detects the 'ShowProperties' event. The enabling item for our trigger is the existence of a 'SEMEventMonitor' System.property in the JVM. JVMs not containing this property will not respond to the trigger and the monitor will go dormant.
Thus, the JVM must be launched with the following option for this monitor to be enabled:
An example STAF command that can trigger this event is:
Nested Class Summary | |
---|---|
protected class |
SEMEventMonitor.STAFMonitor
Polls for the existence of STAF every few seconds until found. |
Field Summary | |
---|---|
protected java.lang.String |
_event
The STAF SEM event trigger that will be monitored. |
protected long |
_msdelay
The milliseconds to wait between checks for STAF and the SEM event. |
protected java.lang.String |
_process
The process name that will be registered with STAF |
protected boolean |
_shutdown
set true to cause this class to go dormant and die. |
protected STAFHelper |
_staf
The STAFHelper we use to talk with STAF. |
protected SEMEventMonitor.STAFMonitor |
_stafmon
The helper STAFMonitor thread that monitors STAF. |
protected java.lang.String |
_system
The JVM System.property used to enable the trigger (for this implementation). |
protected java.lang.Thread |
_thismon
The Thread created by this Runnable instance when monitoring the SEM event. |
static java.lang.String |
DEFAULT_EVENT
'ShowProperties' |
static java.lang.String |
DEFAULT_PROPERTY
'SEMEventMonitor' |
Constructor Summary | |
---|---|
SEMEventMonitor()
Construct a monitor for the event that will be designated during a constructor call to function setEventName. |
Method Summary | |
---|---|
protected void |
finalize()
Allow ourselves to disconnect from STAF. |
protected void |
initialize()
Subclasses should not normally ever need to override this. |
protected boolean |
isTriggerEnabled()
Subclasses override to provide their own enabling algorithm for the performAction function. |
static void |
main(java.lang.String[] args)
For test\debug purposes must launch test JVM with -DSEMEventMonitor=true |
protected void |
performAction()
Default action is to list all System.getProperty values in the org.safs.Log Subclasses will likely want to override this. |
protected void |
resetTrigger()
RESET the SEM Event trigger we are monitoring. |
void |
run()
This is the Runnable thread that will monitor the trigger SEM event. |
protected void |
setEventCriteria()
Subclasses override to designate a unique event to monitor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_EVENT
public static final java.lang.String DEFAULT_PROPERTY
protected java.lang.String _process
protected java.lang.String _event
protected java.lang.String _system
protected STAFHelper _staf
protected boolean _shutdown
protected long _msdelay
protected SEMEventMonitor.STAFMonitor _stafmon
protected java.lang.Thread _thismon
Constructor Detail |
---|
public SEMEventMonitor()
Method Detail |
---|
protected void setEventCriteria()
This default implementation also sets the key name in System.properties that enables the trigger. This key name is stored in the local _system field. The default setting here is DEFAULT_PROPERTY.
protected boolean isTriggerEnabled()
This superclass implementation checks to see if the System.property stored in the _system field is defined in this JVM. The routine will only return true if this JVM has that System.property. This _system field can be set in the setEventCriteria() method if subclasses wish to use this particular isTriggerEnabled() implementation.
protected void initialize()
If isTriggerEnabled returns 'true' then will will register a new STAFMonitor to make the connection with STAF and we will begin monitoring for our special event in a our own run() method as a new Runnable thread.
The process name used to register with STAF is:
protected void resetTrigger()
protected void performAction()
public void run()
Subclasses should not have to override this. The default implementation does NOT reset the trigger event, however, so subclasses wishing to react to multiple occurrences of the trigger will need to reset the event in their performAction function.
run
in interface java.lang.Runnable
protected void finalize() throws java.lang.Exception
finalize
in class java.lang.Object
java.lang.Exception
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |