Class ProposeResponder
-
- All Implemented Interfaces:
FIPANames.InteractionProtocol,Serializable,Serializable
public class ProposeResponder extends FSMBehaviour implements FIPANames.InteractionProtocol
Behaviour class forfipa-proposeResponder role. This behaviour implements thefipa-proposeinteraction protocol from the point of view of a responder to a propose (propose) message.The API of this class is similar and homogeneous to the
AchieveREResponder.When a message arrives that matches the message template passed to the constructor, the callback method
prepareResponseis executed that must return the wished response, for instance theACCEPT_PROPOSALreply message. Any other type of returned communicative act is sent and then closes the protocol.If a message were received, with the same value of this
conversation-id, but that does not comply with the FIPA protocol, than the methodhandleOutOfSequencewould be called.This class can be extended by the programmer by overriding all the needed handle methods or, in alternative, appropriate behaviours can be registered for each handle via the
registerHandle-type of methods. This last case is more difficult to use and proper care must be taken to properly use theDataStoreof theBehaviouras a shared memory mechanism with the registered behaviour.Read carefully the section of the JADE programmer's guide that describes the usage of this class.
- Version:
- $Date$ $Revision$
- Author:
- Jerome Picault - Motorola Labs
- See Also:
ProposeInitiator,AchieveREResponder, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringPREPARE_RESPONSEStringPROPOSE_KEYkey to retrieve from the DataStore of the behaviour the ACLMessage object sent by the initiator.protected static StringRECEIVE_PROPOSEStringRESPONSE_KEYkey to retrieve from the DataStore of the behaviour the ACLMessage object sent as a response to the initiator.protected static StringSEND_RESPONSE-
Fields inherited from class jade.core.behaviours.FSMBehaviour
currentName, lastStates
-
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
-
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
Constructors Constructor Description ProposeResponder(Agent a, MessageTemplate mt)Constructor of the behaviour that creates a new empty DataStoreProposeResponder(Agent a, MessageTemplate mt, DataStore store)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MessageTemplatecreateMessageTemplate(String iprotocol)This static method can be used to set the proper message template (based on the interaction protocol and the performative) into the constructor of this behaviour.protected ACLMessageprepareResponse(ACLMessage propose)This method is called when the initiator's message is received that matches the message template passed in the constructor.voidregisterPrepareResponse(Behaviour b)This method allows to register a user definedBehaviourin the PREPARE_RESPONSE state.voidreset()Reset this behaviour.voidreset(MessageTemplate mt)This method allows to change theMessageTemplatethat defines what messages this ProposeResponder will react to and reset the protocol.-
Methods inherited from class jade.core.behaviours.FSMBehaviour
checkTermination, deregisterDefaultTransition, deregisterState, deregisterTransition, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, hasDefaultTransition, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, resetStates, scheduleFirst, scheduleNext, stringifyTransitionTable
-
Methods inherited from class jade.core.behaviours.SerialBehaviour
handle
-
Methods inherited from class jade.core.behaviours.CompositeBehaviour
action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren, setAgent
-
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, isRunnable, onStart, restart, root, setBehaviourName, setDataStore, setExecutionState
-
-
-
-
Field Detail
-
PROPOSE_KEY
public final String PROPOSE_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage object sent by the initiator.
-
RESPONSE_KEY
public final String RESPONSE_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage object sent as a response to the initiator.
-
RECEIVE_PROPOSE
protected static final String RECEIVE_PROPOSE
- See Also:
- Constant Field Values
-
PREPARE_RESPONSE
protected static final String PREPARE_RESPONSE
- See Also:
- Constant Field Values
-
SEND_RESPONSE
protected static final String SEND_RESPONSE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ProposeResponder
public ProposeResponder(Agent a, MessageTemplate mt)
Constructor of the behaviour that creates a new empty DataStore
-
ProposeResponder
public ProposeResponder(Agent a, MessageTemplate mt, DataStore store)
Constructor.- Parameters:
a- is the reference to the Agent objectmt- is the MessageTemplate that must be used to match the initiator message. Take care that if mt is null every message is consumed by this protocol.store- the DataStore for this protocol
-
-
Method Detail
-
createMessageTemplate
public static MessageTemplate createMessageTemplate(String iprotocol)
This static method can be used to set the proper message template (based on the interaction protocol and the performative) into the constructor of this behaviour.- See Also:
FIPANames.InteractionProtocol
-
reset
public void reset()
Reset this behaviour.- Overrides:
resetin classFSMBehaviour
-
reset
public void reset(MessageTemplate mt)
This method allows to change theMessageTemplatethat defines what messages this ProposeResponder will react to and reset the protocol.
-
prepareResponse
protected ACLMessage prepareResponse(ACLMessage propose) throws NotUnderstoodException, RefuseException
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.- Parameters:
propose- the received message- Returns:
- the ACLMessage to be sent as a response (i.e. one of
accept_proposal, reject_proposal, not-understood. Remind to use the method createReply of the class ACLMessage in order to create a good reply message - Throws:
NotUnderstoodExceptionRefuseException- See Also:
ACLMessage.createReply()
-
registerPrepareResponse
public void registerPrepareResponse(Behaviour b)
This method allows to register a user definedBehaviourin the PREPARE_RESPONSE state. This behaviour would override the homonymous method. This method also set the data store of the registeredBehaviourto the DataStore of this current behaviour. It is responsibility of the registered behaviour to put the response to be sent into the datastore at theRESPONSE_KEYkey.- Parameters:
b- the Behaviour that will handle this state
-
-