jade.proto
Class IteratedAchieveREInitiator

java.lang.Object
  |
  +--jade.core.behaviours.Behaviour
        |
        +--jade.core.behaviours.CompositeBehaviour
              |
              +--jade.core.behaviours.SerialBehaviour
                    |
                    +--jade.core.behaviours.FSMBehaviour
                          |
                          +--jade.proto.Initiator
                                |
                                +--jade.proto.AchieveREInitiator
                                      |
                                      +--jade.proto.IteratedAchieveREInitiator
All Implemented Interfaces:
Serializable, java.io.Serializable

public class IteratedAchieveREInitiator
extends AchieveREInitiator

This class implements the initiator role in the iterated version of fipa-request like interaction protocols. In the iterated version, having received all the result notifications from the responders, the initiator may send further initiation messages. The session of such a protocol with a given responder terminates when one of the followings occurs: i) The initiator sends an explicit CANCEL message instead of the next initiation message to the responder. ii) The responder replies with a negative reply i.e. REFUSE, NOT_UNDERSTOOD or FAILURE ii) The responder attaches a termination flag to an INFORM result notification. That termination flag can be detected using the isSessionTerminated() method.

Author:
Giovanni Caire - TILab
See Also:
Serialized Form

Field Summary
 java.lang.String ALL_NEXT_REQUESTS_KEY
          Key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that will be sent at next round.
static java.lang.String REINIT
           
 
Fields inherited from class jade.proto.AchieveREInitiator
ALL_REQUESTS_KEY, ALL_RESPONSES_KEY, ALL_RESULT_NOTIFICATIONS_KEY, CHECK_AGAIN, HANDLE_AGREE, HANDLE_ALL_RESPONSES, HANDLE_ALL_RESULT_NOTIFICATIONS, HANDLE_INFORM, HANDLE_REFUSE, REPLY_KEY, REQUEST_KEY
 
Fields inherited from class jade.core.behaviours.FSMBehaviour
currentName, lastStates
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent
 
Constructor Summary
IteratedAchieveREInitiator(Agent a, ACLMessage msg)
          Construct an IteratedAchieveREInitiator with an empty DataStore
IteratedAchieveREInitiator(Agent a, ACLMessage msg, DataStore store)
          Construct an IteratedAchieveREInitiator with a given DataStore
 
Method Summary
protected  void handleAllResultNotifications(java.util.Vector resultNotifications)
          This method is redefined to call the proper overloaded method
protected  void handleAllResultNotifications(java.util.Vector resultNotifications, java.util.Vector nextRequests)
          This method is called when all the result notification messages of the current round have been collected.
protected  void handleInform(ACLMessage inform)
          This method is redefined to call the proper overloaded method
protected  void handleInform(ACLMessage inform, java.util.Vector nextRequests)
          This method is called every time an inform message is received, which is not out-of-sequence according to the protocol rules.
static boolean isSessionTerminated(ACLMessage inform)
          Check if the responder has closed the session just after sending this inform message.
 void registerHandleAllResultNotifications(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_ALL_RESULT_NOTIFICATIONS state.
 void registerHandleInform(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_REFUSE state.
 
Methods inherited from class jade.proto.AchieveREInitiator
createConvId, getSession, handleAgree, handleAllResponses, handleFailure, handleNotUnderstood, handleOutOfSequence, handleRefuse, onStart, prepareRequests, registerHandleAgree, registerHandleAllResponses, registerHandleFailure, registerHandleNotUnderstood, registerHandleOutOfSequence, registerHandleRefuse, registerPrepareRequests, reinit, reset, reset, setDataStore
 
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, resetStates, scheduleFirst, scheduleNext
 
Methods inherited from class jade.core.behaviours.CompositeBehaviour
action, block, done, resetChildren, restart, setAgent
 
Methods inherited from class jade.core.behaviours.Behaviour
block, getBehaviourName, getDataStore, getParent, isRunnable, root, setBehaviourName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_NEXT_REQUESTS_KEY

public final java.lang.String ALL_NEXT_REQUESTS_KEY
Key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that will be sent at next round.


REINIT

public static final java.lang.String REINIT
See Also:
Constant Field Values
Constructor Detail

IteratedAchieveREInitiator

public IteratedAchieveREInitiator(Agent a,
                                  ACLMessage msg)
Construct an IteratedAchieveREInitiator with an empty DataStore


IteratedAchieveREInitiator

public IteratedAchieveREInitiator(Agent a,
                                  ACLMessage msg,
                                  DataStore store)
Construct an IteratedAchieveREInitiator with a given DataStore

Parameters:
a - The agent performing the protocol
msg - The message that must be used to initiate the protocol. Notice that the default implementation of the prepareRequest() method returns an array composed of only this message. The values of the slot reply-with is ignored and a different value is assigned automatically by this class for each receiver.
store - The DataStore that will be used by this AchieveREInitiator
Method Detail

handleInform

protected void handleInform(ACLMessage inform,
                            java.util.Vector nextRequests)
This method is called every time an inform message is received, which is not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override this method in case they need to react to this event.

Parameters:
inform - the received inform message

handleInform

protected final void handleInform(ACLMessage inform)
This method is redefined to call the proper overloaded method

Overrides:
handleInform in class AchieveREInitiator
Parameters:
inform - the received inform message

handleAllResultNotifications

protected void handleAllResultNotifications(java.util.Vector resultNotifications,
                                            java.util.Vector nextRequests)
This method is called when all the result notification messages of the current round have been collected. By result notification message we intend here all the inform, failure received messages, which are not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override this method in case they need to react to this event by analysing all the messages in just one call.


handleAllResultNotifications

protected final void handleAllResultNotifications(java.util.Vector resultNotifications)
This method is redefined to call the proper overloaded method

Overrides:
handleAllResultNotifications in class AchieveREInitiator

registerHandleInform

public void registerHandleInform(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_REFUSE state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the received inform ACLMessage object from the datastore at the REPLY_KEY key and the Vector of ACLMessage objects to be sent at next round at the ALL_NEXT_REQUESTS_KEY.

Overrides:
registerHandleInform in class AchieveREInitiator
Parameters:
b - the Behaviour that will handle this state

registerHandleAllResultNotifications

public void registerHandleAllResultNotifications(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_ALL_RESULT_NOTIFICATIONS state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the Vector of ACLMessage objects, received as a result notification, from the datastore at the ALL_RESULT_NOTIFICATIONS_KEY key and the Vector of ACLMessage objects to be sent at next round at the ALL_NEXT_REQUESTS_KEY.

Overrides:
registerHandleAllResultNotifications in class AchieveREInitiator
Parameters:
b - the Behaviour that will handle this state

isSessionTerminated

public static boolean isSessionTerminated(ACLMessage inform)
Check if the responder has closed the session just after sending this inform message.



JADE