hkontrol.core
Class AbstractAction

java.lang.Object
  extended by hkontrol.core.AbstractAction
Direct Known Subclasses:
ActionBase, PrintState, RestartTimer, Send

public abstract class AbstractAction
extends java.lang.Object

AbstractAction is the base class for any action that can be executed by a HKontrol rule.

To implement a new action (named MyAction in module mymodule)

The derived class can use getConfig for details on its configuration.


Constructor Summary
protected AbstractAction()
          The default constructor actually does NOT initialize the object.
 
Method Summary
 void construct(Configuration.Entry config)
          Replaces the empty default constructor and must be called immediately after object instantiation.
abstract  void execute(ImmutableState state)
          Gets called if the action is triggered by a matching rule.
protected  Configuration.Entry getConfig()
           
protected  HKConnection getConnection()
          returns a HKConnection object if a connection is associated with the calling module instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAction

protected AbstractAction()
The default constructor actually does NOT initialize the object. Instead, the contruct method must be called after instantiation. Doing it that way, the derived actions are not being enforced to implement a constructor.

Method Detail

construct

public final void construct(Configuration.Entry config)
Replaces the empty default constructor and must be called immediately after object instantiation. Since construct is final and the creation of action objects take place in the HKontrol core, the derived actions do not need to know anything about the instantiation details.

Parameters:
config - the configuration element referring to the instantiated action.

getConfig

protected Configuration.Entry getConfig()
Returns:
the configuration element referring to the instantiated action

execute

public abstract void execute(ImmutableState state)
Gets called if the action is triggered by a matching rule.


getConnection

protected HKConnection getConnection()
                              throws ModuleException
returns a HKConnection object if a connection is associated with the calling module instance.

Returns:
the associated connection or null if no connection is configured
Throws:
ModuleException - if connection could not be established