Package jade.proto
Class SSContractNetResponder
- java.lang.Object
-
- jade.core.behaviours.Behaviour
-
- jade.core.behaviours.CompositeBehaviour
-
- jade.core.behaviours.SerialBehaviour
-
- jade.core.behaviours.FSMBehaviour
-
- jade.proto.SSContractNetResponder
-
- All Implemented Interfaces:
Serializable,Serializable
- Direct Known Subclasses:
ContractNetResponder,SSIteratedContractNetResponder
public class SSContractNetResponder extends FSMBehaviour
Single Session version of the Responder role in the Fipa-Contract-Net protocol.- 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 Modifier and Type Field Description StringACCEPT_PROPOSAL_KEYKey to retrieve from the DataStore of the behaviour the last received ACCEPT_PROPOSAL ACLMessageStringCFP_KEYKey to retrieve from the DataStore of the behaviour the last received CFP ACLMessageprotected static StringCHECK_IN_SEQprotected static StringDUMMY_FINALstatic StringHANDLE_ACCEPT_PROPOSALstatic StringHANDLE_CFPprotected static StringHANDLE_OUT_OF_SEQUENCEstatic StringHANDLE_REJECT_PROPOSALStringINITIATION_KEYKey to retrieve from the DataStore of the behaviour the initiation ACLMessage that triggered this responder sessionStringPROPOSE_KEYKey to retrieve from the DataStore of the behaviour the last sent PROPOSE ACLMessageprotected static StringRECEIVE_NEXTStringRECEIVED_KEYKey to retrieve from the DataStore of the behaviour the last received ACLMessageStringREJECT_PROPOSAL_KEYKey to retrieve from the DataStore of the behaviour the last received REJECT_PROPOSAL ACLMessageStringREPLY_KEYKey to set into the DataStore of the behaviour the new ACLMessage to be sent back to the initiator as a reply.protected static StringSEND_REPLY-
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
-
-
Constructor Summary
Constructors Constructor Description SSContractNetResponder(Agent a, ACLMessage cfp)Construct a SSContractNetResponder that is activated by the reception of a given initiation CFP message.SSContractNetResponder(Agent a, ACLMessage cfp, DataStore store)Construct a SSContractNetResponder that is activated by the reception of a given initiation CFP message and uses a given DataStore.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterReply(ACLMessage reply)This method can be redefined by protocol specific implementations to update the status of the protocol just after a reply has been sent.protected voidbeforeReply(ACLMessage reply)This method can be redefined by protocol specific implementations to customize a reply that is going to be sent back to the initiator.protected booleancheckInSequence(ACLMessage received)Check whether a received message complies with the protocol rules.protected ACLMessagehandleAcceptProposal(ACLMessage cfp, ACLMessage propose, ACLMessage accept)This method is called when an ACCEPT_PROPOSAL message is received from the initiator.protected ACLMessagehandleCfp(ACLMessage cfp)This method is called to handle the initial CFP message.protected voidhandleOutOfSequence(ACLMessage msg)Redefine this method to call the overloaded version with 3 parameters.protected voidhandleOutOfSequence(ACLMessage cfp, ACLMessage propose, ACLMessage msg)This method is called whenever a message is received that does not comply to the protocol rules.protected voidhandleRejectProposal(ACLMessage cfp, ACLMessage propose, ACLMessage reject)This method is called when a REJECT_PROPOSAL message is received from the initiator.voidonStart()This method is just an empty placeholders for subclasses.protected voidregisterDSState(Behaviour b, String name)Utility method to register a behaviour in a state of the protocol and set the DataStore appropriatelyvoidregisterHandleAcceptProposal(Behaviour b)This method allows to register a user definedBehaviourin the HANDLE_ACCEPT_PROPOSAL state.voidregisterHandleCfp(Behaviour b)This method allows to register a user definedBehaviourin the HANDLE_CFP state.voidregisterHandleOutOfSequence(Behaviour b)This method allows to register a user definedBehaviourin the HANDLE_OUT_OF_SEQ state.voidregisterHandleRejectProposal(Behaviour b)This method allows to register a user definedBehaviourin the HANDLE_REJECT_PROPOSAL state.protected voidreinit()Re-initialize the internal state without performing a complete reset.voidreset()Reset this behaviour.protected voidsessionTerminated()This method can be redefined by protocol specific implementations to take proper actions after the completion of the current protocol session.-
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, restart, root, setBehaviourName, setDataStore, setExecutionState
-
-
-
-
Field Detail
-
CFP_KEY
public final String CFP_KEY
Key to retrieve from the DataStore of the behaviour the last received CFP ACLMessage
-
PROPOSE_KEY
public final String PROPOSE_KEY
Key to retrieve from the DataStore of the behaviour the last sent PROPOSE ACLMessage
-
ACCEPT_PROPOSAL_KEY
public final String ACCEPT_PROPOSAL_KEY
Key to retrieve from the DataStore of the behaviour the last received ACCEPT_PROPOSAL ACLMessage
-
REJECT_PROPOSAL_KEY
public final String REJECT_PROPOSAL_KEY
Key to retrieve from the DataStore of the behaviour the last received REJECT_PROPOSAL ACLMessage
-
HANDLE_CFP
public static final String HANDLE_CFP
- See Also:
- Constant Field Values
-
HANDLE_ACCEPT_PROPOSAL
public static final String HANDLE_ACCEPT_PROPOSAL
- See Also:
- Constant Field Values
-
HANDLE_REJECT_PROPOSAL
public static final String HANDLE_REJECT_PROPOSAL
- See Also:
- Constant Field Values
-
INITIATION_KEY
public final String INITIATION_KEY
Key to retrieve from the DataStore of the behaviour the initiation ACLMessage that triggered this responder session
-
RECEIVED_KEY
public final String RECEIVED_KEY
Key to retrieve from the DataStore of the behaviour the last received ACLMessage
-
REPLY_KEY
public final String REPLY_KEY
Key to set into the DataStore of the behaviour the new ACLMessage to be sent back to the initiator as a reply.
-
RECEIVE_NEXT
protected static final String RECEIVE_NEXT
- See Also:
- Constant Field Values
-
CHECK_IN_SEQ
protected static final String CHECK_IN_SEQ
- See Also:
- Constant Field Values
-
HANDLE_OUT_OF_SEQUENCE
protected static final String HANDLE_OUT_OF_SEQUENCE
- See Also:
- Constant Field Values
-
SEND_REPLY
protected static final String SEND_REPLY
- See Also:
- Constant Field Values
-
DUMMY_FINAL
protected static final String DUMMY_FINAL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SSContractNetResponder
public SSContractNetResponder(Agent a, ACLMessage cfp)
Construct a SSContractNetResponder that is activated by the reception of a given initiation CFP message.
-
SSContractNetResponder
public SSContractNetResponder(Agent a, ACLMessage cfp, DataStore store)
Construct a SSContractNetResponder that is activated by the reception of a given initiation CFP message and uses a given DataStore.
-
-
Method Detail
-
handleCfp
protected ACLMessage handleCfp(ACLMessage cfp) throws RefuseException, FailureException, NotUnderstoodException
This method is called to handle the initial CFP message. This default implementation does nothing and returns null. Programmers have to override it to react to this event.- Parameters:
cfp- the initial CFP message to handle.- Returns:
- the reply message to be sent back to the initiator. Returning a message different than PROPOSE (or returning null) terminates the protocol.
- Throws:
RefuseException- if the CFP is refused. Throwing a RefuseException has the same effect as returning a REFUSE message, but automatically manages the:contentslot.FailureException- if there is an error serving the CFP. Throwing a FailureException has the same effect as returning a FAILURE message, but automatically manages the:contentslot.NotUnderstoodException- if the CFP content is not understood. Throwing a NotUnderstoodException has the same effect as returning a NOT_UNDERSTOOD message, but automatically manages the:contentslot.
-
handleAcceptProposal
protected ACLMessage handleAcceptProposal(ACLMessage cfp, ACLMessage propose, ACLMessage accept) throws FailureException
This method is called when an ACCEPT_PROPOSAL message is received from the initiator. This default implementation does nothing and returns null. Programmers have to override it to react to this event.- Parameters:
cfp- the initial CFP message.propose- the PROPOSE message sent back as reply to the initial CFP message.accept- the received ACCEPT_PROPOSAL message.- Returns:
- the reply message to be sent back to the initiator.
- Throws:
FailureException- if there is an error serving the ACCEPT_PROPOSAL. Throwing a FailureException has the same effect as returning a FAILURE message, but automatically manages the:contentslot.
-
handleRejectProposal
protected void handleRejectProposal(ACLMessage cfp, ACLMessage propose, ACLMessage reject)
This method is called when a REJECT_PROPOSAL message is received from the initiator. This default implementation does nothing. Programmers may override it to react to this event.- Parameters:
cfp- the initial CFP message.propose- the PROPOSE message sent back as reply to the initial CFP message.reject- the received REJECT_PROPOSAL message or null if no acceptance message is received from the initiator within the timeout specified in the:reply-byslot of the PROPOSE message.
-
handleOutOfSequence
protected void handleOutOfSequence(ACLMessage cfp, ACLMessage propose, ACLMessage msg)
This method is called whenever a message is received that does not comply to the protocol rules. This default implementation does nothing. Programmers may override it in case they need to react to this event.- Parameters:
cfp- the initial CFP message.propose- the PROPOSE message sent back as reply to the initial CFP message.msg- the received out-of-sequence message.
-
registerHandleCfp
public void registerHandleCfp(Behaviour b)
This method allows to register a user definedBehaviourin the HANDLE_CFP state. This behaviour would override the homonymous method. This method also sets the data store of the registeredBehaviourto the DataStore of this current behaviour.
The registered behaviour can retrieve the initialCFPmessage from the datastore at theCFP_KEYkey.
It is responsibility of the registered behaviour to put the reply to be sent back to the initiator into the datastore at theREPLY_KEYkey. Putting a message defferent from PROPOSE (or putting no message) terminates the protocol.- Parameters:
b- the Behaviour that will handle this state
-
registerHandleAcceptProposal
public void registerHandleAcceptProposal(Behaviour b)
This method allows to register a user definedBehaviourin the HANDLE_ACCEPT_PROPOSAL state. This behaviour would override the homonymous method. This method also sets the data store of the registeredBehaviourto the DataStore of this current behaviour.
The registered behaviour can retrieve the receivedACCEPT_PROPOSALmessage from the datastore at theACCEPT_PROPOSAL_KEYkey, the initialCFPmessage at theCFP_KEYand the previously sentPROPOSEmessage at thePROPOSE_KEY.
It is responsibility of the registered behaviour to put the reply to be sent back to the initiator into the datastore at theREPLY_KEYkey.- Parameters:
b- the Behaviour that will handle this state
-
registerHandleRejectProposal
public void registerHandleRejectProposal(Behaviour b)
This method allows to register a user definedBehaviourin the HANDLE_REJECT_PROPOSAL state. This behaviour would override the homonymous method. This method also sets the data store of the registeredBehaviourto the DataStore of this current behaviour.
The registered behaviour can retrieve the receivedREJECT_PROPOSALmessage from the datastore at theREJECT_PROPOSAL_KEYkey, the initialCFPmessage at theCFP_KEYand the previously sentPROPOSEmessage at thePROPOSE_KEY.- Parameters:
b- the Behaviour that will handle this state
-
reinit
protected void reinit()
Re-initialize the internal state without performing a complete reset.
-
handleOutOfSequence
protected void handleOutOfSequence(ACLMessage msg)
Redefine this method to call the overloaded version with 3 parameters.- Parameters:
msg- the received out-of-sequence message.
-
checkInSequence
protected boolean checkInSequence(ACLMessage received)
Check whether a received message complies with the protocol rules.
-
beforeReply
protected void beforeReply(ACLMessage reply)
This method can be redefined by protocol specific implementations to customize a reply that is going to be sent back to the initiator. This default implementation does nothing.
-
afterReply
protected void afterReply(ACLMessage reply)
This method can be redefined by protocol specific implementations to update the status of the protocol just after a reply has been sent. This default implementation does nothing.
-
onStart
public void onStart()
Description copied from class:BehaviourThis 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 thisBehaviour.
-
registerHandleOutOfSequence
public void registerHandleOutOfSequence(Behaviour b)
This method allows to register a user definedBehaviourin the HANDLE_OUT_OF_SEQ state. This behaviour would override the homonymous method. This method also sets the data store of the registeredBehaviourto the DataStore of this current behaviour. The registered behaviour can retrieve theout of sequenceACLMessage object received from the datastore at theRECEIVED_KEYkey.- Parameters:
b- the Behaviour that will handle this state
-
reset
public void reset()
Reset this behaviour.- Overrides:
resetin classFSMBehaviour
-
sessionTerminated
protected void sessionTerminated()
This method can be redefined by protocol specific implementations to take proper actions after the completion of the current protocol session.
-
-