ibspan.tss.messaging
Class RequestHandler

java.lang.Object
  extended by jade.core.behaviours.Behaviour
      extended by jade.core.behaviours.SimpleBehaviour
          extended by jade.core.behaviours.OneShotBehaviour
              extended by ibspan.tss.messaging.RequestHandler
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
FindRestaurantHandler, GetDomainOntologyHandler, GetRestaurantsDetailsHandler, GetUserProfileHandler, InitUserProfileHandler, LogoutHandler, ViewTransformer

public abstract class RequestHandler
extends OneShotBehaviour

This is simple behaviour class for responding to the requests with defined Action object. The behaviours: (1) prepares the response by invoking prepareResponse() method (which should be implemented by the developer) and (2) put it in local datastore.

Author:
Maciej Gawinecki
See Also:
ActionDispatcher, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
 
Field Summary
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
 
Constructor Summary
RequestHandler(Agent a, DataStore ds, Object requestKey, Object actKey, Object resultNotificationKey)
          Constructs RequestHandler.
 
Method Summary
 void action()
          Two-stepped behaviour: (1) invokes and #prepareResponse(ACLMessage,Action method (2) puts returned response in local datastore.
protected abstract  ACLMessage prepareResponse(ACLMessage request, Action act)
          Returns response to the request.
 
Methods inherited from class jade.core.behaviours.OneShotBehaviour
done
 
Methods inherited from class jade.core.behaviours.SimpleBehaviour
reset
 
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, block, getBehaviourName, getDataStore, getExecutionState, getParent, handle, isRunnable, onEnd, onStart, restart, root, setAgent, setBehaviourName, setDataStore, setExecutionState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestHandler

public RequestHandler(Agent a,
                      DataStore ds,
                      Object requestKey,
                      Object actKey,
                      Object resultNotificationKey)
Constructs RequestHandler.

Parameters:
a - is the agent owning this behaviour.
ds - is the Datastore for this RequestHandler.
requestKey - is key pointing the place in local datastore, where incoming request can be found.
actKey - is key in the DataStore where the Action concept extracted by the action dispatcher from current request can be found.
resultNotificationKey - is key to retrieve from the DataStore of the behaviour the ACLMessage object sent as a result notification to the initiator.
Method Detail

action

public final void action()
Two-stepped behaviour: (1) invokes and #prepareResponse(ACLMessage,Action method (2) puts returned response in local datastore.

Specified by:
action in class Behaviour

prepareResponse

protected abstract ACLMessage prepareResponse(ACLMessage request,
                                              Action act)
                                       throws NotUnderstoodException,
                                              FailureException
Returns response to the request. Programmers should implenets this method in order process given request.

Parameters:
request - is message.
act - is Action concept extracted previously from request object.
Returns:
response; null means failure.
Throws:
NotReadableRequestException - when it is not possible to parse request message.
NotFormableResponseException - when it is not possible to form response message.
NotUnderstoodException
FailureException