Package jade.proto
Class AchieveREResponder
-
- All Implemented Interfaces:
FIPANames.InteractionProtocol,Serializable,Serializable
public class AchieveREResponder extends FSMBehaviour 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.- Version:
- $Date$ $Revision$
- Author:
- Giovanni Caire - TILab, Fabio Bellifemine - TILab, Tiziana Trucco - TILab
- See Also:
AchieveREInitiator, 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_KEYkey to retrieve from the DataStore of the behaviour the ACLMessage object sent by the initiator.StringRESPONSE_KEYkey to retrieve from the DataStore of the behaviour the ACLMessage object sent as a response to the initiator.StringRESULT_NOTIFICATION_KEYkey to retrieve from the DataStore of the behaviour the ACLMessage object sent as a result notification to the initiator.-
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 AchieveREResponder(Agent a, MessageTemplate mt)Constructor of the behaviour that creates a new empty DataStoreAchieveREResponder(Agent a, MessageTemplate mt, DataStore store)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated 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 ACLMessagehandleRequest(ACLMessage request)This method is called when the protocol initiation message (matching the MessageTemplate specified in the constructor) is received.protected ACLMessageprepareResponse(ACLMessage request)Deprecated.Use handleRequest() insteadprotected ACLMessageprepareResultNotification(ACLMessage request, ACLMessage response)This method is called after the execution of the handleRequest() method if no response was sent or the response was anAGREEmessage.voidregisterHandleRequest(Behaviour b)This method allows to register a user definedBehaviourin the HANDLE_REQUEST state.voidregisterPrepareResponse(Behaviour b)Deprecated.Use registerHandleRequest() instead.voidregisterPrepareResultNotification(Behaviour b)This method allows to register a user definedBehaviourin the PREPARE_RESULT_NOTIFICATION state.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.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
-
REQUEST_KEY
public final String REQUEST_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.
-
RESULT_NOTIFICATION_KEY
public final String RESULT_NOTIFICATION_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage object sent as a result notification to the initiator.
-
-
Constructor Detail
-
AchieveREResponder
public AchieveREResponder(Agent a, MessageTemplate mt)
Constructor of the behaviour that creates a new empty DataStore
-
AchieveREResponder
public AchieveREResponder(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 using the same MessageTemplate.- Overrides:
resetin classFSMBehaviour
-
reset
public void reset(MessageTemplate mt)
This method allows to change theMessageTemplatethat defines what messages this FIPARequestResponder will react to and reset the protocol.
-
handleRequest
protected ACLMessage handleRequest(ACLMessage request) throws NotUnderstoodException, RefuseException
This method is called when the protocol initiation message (matching the MessageTemplate specified in the constructor) is received. This default implementation returns null which has the effect of sending no reponse. Programmers should override this 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. - Throws:
NotUnderstoodExceptionRefuseException
-
prepareResponse
protected ACLMessage prepareResponse(ACLMessage request) throws NotUnderstoodException, RefuseException
Deprecated.Use handleRequest() instead
-
prepareResultNotification
protected ACLMessage prepareResultNotification(ACLMessage request, ACLMessage response) throws FailureException
This method is called after the execution of the handleRequest() method if no response was sent or the response was anAGREEmessage. This default implementation returns 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. - Throws:
FailureException- See Also:
handleRequest(ACLMessage)
-
registerHandleRequest
public void registerHandleRequest(Behaviour b)
This method allows to register a user definedBehaviourin the HANDLE_REQUEST state. This behaviour would override the homonymous method. This method also set the DataStore of the registeredBehaviourto the DataStore of this AchieveREResponder. 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
-
registerPrepareResponse
public void registerPrepareResponse(Behaviour b)
Deprecated.Use registerHandleRequest() instead.
-
registerPrepareResultNotification
public void registerPrepareResultNotification(Behaviour b)
This method allows to register a user definedBehaviourin the PREPARE_RESULT_NOTIFICATION state. This behaviour would override the homonymous method. This method also set the DataStore of the registeredBehaviourto the DataStore of this AchieveREResponder. It is responsibility of the registered behaviour to put the result notification message to be sent into the DataStore at theRESULT_NOTIFICATION_KEYkey.- Parameters:
b- the Behaviour that will handle this state
-
-