ibspan.tss.messaging
Class SafeHandlerSelector

java.lang.Object
  extended by jade.core.behaviours.Behaviour
      extended by jade.core.behaviours.CompositeBehaviour
          extended by jade.core.behaviours.SerialBehaviour
              extended by jade.core.behaviours.FSMBehaviour
                  extended by jade.proto.states.HandlerSelector
                      extended by ibspan.tss.messaging.SafeHandlerSelector
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ActionDispatcher, ActionDispatcherWithSessionTracking, PersonalActionDispatcher

public abstract class SafeHandlerSelector
extends HandlerSelector

Extends functionality of HandlerSelector by providing registerErrorHandler(Behaviour) method for registering behaviour, which handles with situation in which no behaviour for the given request is registered or an error occured during dispatching.

Author:
Maciej Gawinecki
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
 
Field Summary
 
Fields inherited from class jade.proto.states.HandlerSelector
SELECTION_NOK, SELECTION_OK
 
Fields inherited from class jade.core.behaviours.FSMBehaviour
currentName, lastStates, previousName
 
Fields inherited from class jade.core.behaviours.CompositeBehaviour
currentExecuted
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
 
Constructor Summary
SafeHandlerSelector(Agent a, DataStore s, Object accessKey)
          Constructor for this SafeHandlerSelector.
 
Method Summary
protected abstract  Object getSelectionKey_internal(Object o)
          Subclasses must provide a concrete implementation for this method.
protected  Object getSelectionKey(Object o)
          Returns the key to which the handler was bound.
 void registerErrorHandler(Behaviour h)
          Register behaviour which will handle with situations in which action dispatcher cannot process request or the this no handler for the request.
 
Methods inherited from class jade.proto.states.HandlerSelector
registerHandler
 
Methods inherited from class jade.core.behaviours.FSMBehaviour
checkTermination, deregisterState, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, reset, resetStates, scheduleFirst, scheduleNext
 
Methods inherited from class jade.core.behaviours.SerialBehaviour
handle
 
Methods inherited from class jade.core.behaviours.CompositeBehaviour
action, block, done, registerAsChild, resetChildren, restart, setAgent
 
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, getBehaviourName, getDataStore, getExecutionState, getParent, isRunnable, onStart, root, setBehaviourName, setDataStore, setExecutionState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeHandlerSelector

public SafeHandlerSelector(Agent a,
                           DataStore s,
                           Object accessKey)
Constructor for this SafeHandlerSelector.

Parameters:
a - is a reference to the Agent object
s - is the DataStore where the object can be retrieved from
accessKey - is the key to get the proper object from the DataStore, this is the object that will be later passed as argument to the method getSelectionKey
See Also:
getSelectionKey(Object)
Method Detail

getSelectionKey

protected final Object getSelectionKey(Object o)
Returns the key to which the handler was bound. Invokes getSelectionKey_internal method.

Specified by:
getSelectionKey in class HandlerSelector
Parameters:
selectionVar - is the object retrieved from the datastore at the accessKey passed in the constructor
Returns:
the key to which the handler was bound; if key was not found or error occured (signalled as catched exception) then key for error handler is returned.
See Also:
registerErrorHandler(Behaviour), getSelectionKey_internal(Object)

getSelectionKey_internal

protected abstract Object getSelectionKey_internal(Object o)
                                            throws Exception
Subclasses must provide a concrete implementation for this method. It must return the key to which the handler was bound.

Parameters:
selectionVar - the object retrieved from the datastore at the accessKey passed in the constructor
Returns:
the key to which the handler was bound
Throws:
Exception

registerErrorHandler

public void registerErrorHandler(Behaviour h)
Register behaviour which will handle with situations in which action dispatcher cannot process request or the this no handler for the request.

Parameters:
h - error handler