Package jade.proto
Class SimpleAchieveREResponder
- java.lang.Object
-
- jade.core.behaviours.Behaviour
-
- jade.core.behaviours.SimpleBehaviour
-
- jade.proto.SimpleAchieveREResponder
-
- All Implemented Interfaces:
FIPANames.InteractionProtocol,Serializable,Serializable
- Direct Known Subclasses:
RequestManagementBehaviour
public class SimpleAchieveREResponder extends SimpleBehaviour implements FIPANames.InteractionProtocol
This is a single homogeneous and effective implementation of all the FIPA-Request-like interaction protocols defined by FIPA, that is all those protocols where the initiator sends a single message (i.e. it performs a single communicative act) within the scope of an interaction protocol in order to verify if the RE (Rational Effect) of the communicative act has been achieved or not. Note that this is a simple implementation of theAchieveREResponder. that does not allow to register Behaviour for the Prepare Response and Prepare Result Notification states of the protocol- Version:
- $Date$ $Revision$
- Author:
- Tiziana Trucco - TILab
- See Also:
SimpleAchieveREInitiator,AchieveREInitiator,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 StringREQUEST_KEYStringRESPONSE_KEYStringRESULT_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
Constructors Constructor Description SimpleAchieveREResponder(Agent a, MessageTemplate mt)Constructor of the behaviour that creates a new empty DataStoreSimpleAchieveREResponder(Agent a, MessageTemplate mt, DataStore store)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaction()Runs the behaviour.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.booleandone()This method checks whether this behaviour has finished or not.protected ACLMessageprepareResponse(ACLMessage request)This method is called when the initiator's message is received that matches the message template passed in the constructor.protected ACLMessageprepareResultNotification(ACLMessage request, ACLMessage response)This method is called after the response has been sent and only when one of the folliwing two cases arise: the response was anagreemessage OR no response message was sent.voidreset()Reset this behaviour using the same MessageTemplate.voidreset(MessageTemplate mt)This method allows to change theMessageTemplatethat defines what messages this FIPARequestResponder will react to and reset the protocol.-
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, handle, handleBlockEvent, handleRestartEvent, isRunnable, onEnd, onStart, restart, root, setAgent, setBehaviourName, setDataStore, setExecutionState
-
-
-
-
Field Detail
-
REQUEST_KEY
public final String REQUEST_KEY
- See Also:
AchieveREResponder.REQUEST_KEY
-
RESPONSE_KEY
public final String RESPONSE_KEY
- See Also:
AchieveREResponder.RESPONSE_KEY
-
RESULT_NOTIFICATION_KEY
public final String RESULT_NOTIFICATION_KEY
-
-
Constructor Detail
-
SimpleAchieveREResponder
public SimpleAchieveREResponder(Agent a, MessageTemplate mt)
Constructor of the behaviour that creates a new empty DataStore
-
SimpleAchieveREResponder
public SimpleAchieveREResponder(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
-
action
public final void action()
Description copied from class:BehaviourRuns the behaviour. This abstract method must be implemented byBehavioursubclasses to perform ordinary behaviour duty. An agent schedules its behaviours calling theiraction()method; since all the behaviours belonging to the same agent are scheduled cooperatively, this method must not enter in an endless loop and should return as soon as possible to preserve agent responsiveness. To split a long and slow task into smaller section, recursive behaviour aggregation may be used.- Specified by:
actionin classBehaviour- See Also:
CompositeBehaviour
-
prepareResponse
protected ACLMessage prepareResponse(ACLMessage request) 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:
request- the received message- Returns:
- the ACLMessage to be sent as a response (i.e. one of
agree, refuse, not-understood, inform. Remind to use the method createReply of the class ACLMessage in order to create a good reply message - Throws:
NotUnderstoodExceptionRefuseException- See Also:
ACLMessage.createReply()
-
prepareResultNotification
protected ACLMessage prepareResultNotification(ACLMessage request, ACLMessage response) throws FailureException
This method is called after the response has been sent and only when one of the folliwing two cases arise: the response was anagreemessage OR no response message was sent. This default implementation return null which has the effect of sending no result notification. Programmers should override the method in case they need to react to this event.- Parameters:
request- the received messageresponse- 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(),prepareResponse(ACLMessage)
-
reset
public void reset()
Reset this behaviour using the same MessageTemplate.- Overrides:
resetin classSimpleBehaviour
-
reset
public void reset(MessageTemplate mt)
This method allows to change theMessageTemplatethat defines what messages this FIPARequestResponder will react to and reset the protocol.
-
-