jade.domain
Class RequestManagementBehaviour

java.lang.Object
  extended by jade.core.behaviours.Behaviour
      extended by jade.core.behaviours.SimpleBehaviour
          extended by jade.proto.SimpleAchieveREResponder
              extended by jade.domain.RequestManagementBehaviour
All Implemented Interfaces:
FIPANames.InteractionProtocol, java.io.Serializable

public abstract class RequestManagementBehaviour
extends SimpleAchieveREResponder

Base class for AMS and DF behaviours managing requests from agents. This class handles the FIPA-request protocol and in particular prepares the response taking into account all possible exceptions. The preparation of the result notification is delegated to subclasses as its form (RESULT or DONE) and sending time (i.e. whether it can be sent immediately or must be delayed at a later time) depends on the specific action.

Author:
Giovanni Caire - Tilab
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.SimpleAchieveREResponder
REQUEST_KEY, RESPONSE_KEY, RESULT_NOTIFICATION_KEY
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
 
Fields inherited from interface jade.domain.FIPANames.InteractionProtocol
FIPA_BROKERING, FIPA_CONTRACT_NET, FIPA_DUTCH_AUCTION, FIPA_ENGLISH_AUCTION, FIPA_ITERATED_CONTRACT_NET, FIPA_PROPOSE, FIPA_QUERY, FIPA_RECRUITING, FIPA_REQUEST, FIPA_REQUEST_WHEN, FIPA_SUBSCRIBE, ITERATED_FIPA_REQUEST
 
Constructor Summary
protected RequestManagementBehaviour(Agent a, MessageTemplate mt)
           
 
Method Summary
 void onStart()
          This method is just an empty placeholders for subclasses.
protected abstract  ACLMessage performAction(Action slAction, ACLMessage request)
           
protected  ACLMessage prepareResponse(ACLMessage request)
          This method is called when the initiator's message is received that matches the message template passed in the constructor.
protected  ACLMessage prepareResultNotification(ACLMessage request, ACLMessage response)
          Just return the (already prepared) notification message (if any).
 void reset()
          Reset this behaviour using the same MessageTemplate.
 
Methods inherited from class jade.proto.SimpleAchieveREResponder
action, createMessageTemplate, done, reset
 
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, block, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, handle, handleBlockEvent, handleRestartEvent, isRunnable, onEnd, 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

RequestManagementBehaviour

protected RequestManagementBehaviour(Agent a,
                                     MessageTemplate mt)
Method Detail

onStart

public void onStart()
Description copied from class: Behaviour
This method is just an empty placeholders for subclasses. It is executed just once before starting behaviour execution. Therefore, it acts as a prolog to the task represented by this Behaviour.

Overrides:
onStart in class Behaviour

performAction

protected abstract ACLMessage performAction(Action slAction,
                                            ACLMessage request)
                                     throws jade.security.JADESecurityException,
                                            FIPAException
Throws:
jade.security.JADESecurityException
FIPAException

prepareResponse

protected ACLMessage prepareResponse(ACLMessage request)
                              throws NotUnderstoodException,
                                     RefuseException
Description copied from class: SimpleAchieveREResponder
This method is called when the initiator's message is received that matches the message template passed in the constructor. This default implementation return null which has the effect of sending no reponse. Programmers should override the method in case they need to react to this event.

Overrides:
prepareResponse in class SimpleAchieveREResponder
Parameters:
request - the received message
Returns:
null when the AGREE message can be skipper, the AGREE message otherwise.
Throws:
NotUnderstoodException
RefuseException
See Also:
ACLMessage.createReply()

prepareResultNotification

protected ACLMessage prepareResultNotification(ACLMessage request,
                                               ACLMessage response)
                                        throws FailureException
Just return the (already prepared) notification message (if any).

Overrides:
prepareResultNotification in class SimpleAchieveREResponder
Parameters:
request - the received message
response - the previously sent response message
Returns:
the ACLMessage to be sent as a result notification (i.e. one of inform, failure. Remind to use the method createReply of the class ACLMessage in order to create a good reply message
Throws:
FailureException
See Also:
ACLMessage.createReply(), SimpleAchieveREResponder.prepareResponse(ACLMessage)

reset

public void reset()
Description copied from class: SimpleAchieveREResponder
Reset this behaviour using the same MessageTemplate.

Overrides:
reset in class SimpleAchieveREResponder