jade.proto
Class ContractNetResponder

java.lang.Object
  |
  +--jade.core.behaviours.Behaviour
        |
        +--jade.core.behaviours.CompositeBehaviour
              |
              +--jade.core.behaviours.SerialBehaviour
                    |
                    +--jade.core.behaviours.FSMBehaviour
                          |
                          +--jade.proto.SSResponder
                                |
                                +--jade.proto.SSContractNetResponder
                                      |
                                      +--jade.proto.ContractNetResponder
All Implemented Interfaces:
Serializable, java.io.Serializable

public class ContractNetResponder
extends SSContractNetResponder

Behaviour class for fipa-contract-net Responder role. This behaviour implements the fipa-contract-net interaction protocol from the point of view of a responder to a call for proposal (cfp) message.

The API of this class is similar and homogeneous to the AchieveREResponder.

Read also the introduction to ContractNetInitiator for a description of the protocol.

When a message arrives that matches the message template passed to the constructor, the callback method prepareResponse is executed that must return the wished response, for instance the PROPOSE reply message. Any other type of returned communicative act is sent and then closes the protocol.

Then, if the initiator accepted the proposal, i.e. if an ACCEPT-PROPOSAL message was received, the callback method prepareResultNotification would be executed that must return the message with the result notification, i.e. INFORM or FAILURE.
In alternative, if the initiator rejected the proposal, i.e. if an REJECT-PROPOSAL message was received, the callback method handleRejectProposal would be executed and the protocol terminated.

If a message were received, with the same value of this conversation-id, but that does not comply with the FIPA protocol, than the method handleOutOfSequence would 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 the DataStore of the Behaviour as 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: 2006-05-25 15:29:42 +0200 (gio, 25 mag 2006) $ $Revision: 5884 $
Author:
Fabio Bellifemine - TILAB, Giovanni Caire - TILAB, Marco Monticone - TILAB
See Also:
ContractNetInitiator, AchieveREResponder, Serialized Form

Field Summary
 java.lang.String PROPOSE_ACCEPTANCE_KEY
          Deprecated. Use either ACCEPT_PROPOSAL_KEY or REJECT_PROPOSAL_KEY according to the message that has been received
static java.lang.String RECEIVE_CFP
           
 java.lang.String RESPONSE_KEY
          Deprecated. Use REPLY_KEY
 java.lang.String RESULT_NOTIFICATION_KEY
          Deprecated. Use REPLY_KEY
 
Fields inherited from class jade.proto.SSContractNetResponder
ACCEPT_PROPOSAL_KEY, CFP_KEY, HANDLE_ACCEPT_PROPOSAL, HANDLE_CFP, HANDLE_REJECT_PROPOSAL, INITIATION_KEY, PROPOSE_KEY, RECEIVED_KEY, REJECT_PROPOSAL_KEY, REPLY_KEY
 
Fields inherited from class jade.core.behaviours.FSMBehaviour
currentName, lastStates
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent
 
Constructor Summary
ContractNetResponder(Agent a, MessageTemplate mt)
          Constructor of the behaviour that creates a new empty DataStore
ContractNetResponder(Agent a, MessageTemplate mt, DataStore store)
          Constructor of the behaviour.
 
Method Summary
static MessageTemplate createMessageTemplate(java.lang.String iprotocol)
          This static method can be used to set the proper message Template (based on the interaction protocol and the performative) to be passed to the constructor of this behaviour.
protected  ACLMessage prepareResponse(ACLMessage cfp)
          Deprecated. Use handleCfp() instead
protected  ACLMessage prepareResultNotification(ACLMessage cfp, ACLMessage propose, ACLMessage accept)
          Deprecated. Use handleAcceptProposal() instead.
 void registerPrepareResponse(Behaviour b)
          Deprecated. Use registerHandleCfp() instead.
 void registerPrepareResultNotification(Behaviour b)
          Deprecated. Use registerHandleAcceptProposal() instead.
 
Methods inherited from class jade.proto.SSContractNetResponder
handleAcceptProposal, handleCfp, handleOutOfSequence, handleOutOfSequence, handleRejectProposal, registerHandleAcceptProposal, registerHandleCfp, registerHandleOutOfSequence, registerHandleRejectProposal, reinit, reset
 
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, onStart, root, setBehaviourName, setDataStore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESPONSE_KEY

public final java.lang.String RESPONSE_KEY
Deprecated. Use REPLY_KEY


PROPOSE_ACCEPTANCE_KEY

public final java.lang.String PROPOSE_ACCEPTANCE_KEY
Deprecated. Use either ACCEPT_PROPOSAL_KEY or REJECT_PROPOSAL_KEY according to the message that has been received


RESULT_NOTIFICATION_KEY

public final java.lang.String RESULT_NOTIFICATION_KEY
Deprecated. Use REPLY_KEY


RECEIVE_CFP

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

ContractNetResponder

public ContractNetResponder(Agent a,
                            MessageTemplate mt)
Constructor of the behaviour that creates a new empty DataStore

See Also:
ContractNetResponder(Agent a, MessageTemplate mt, DataStore store)

ContractNetResponder

public ContractNetResponder(Agent a,
                            MessageTemplate mt,
                            DataStore store)
Constructor of the behaviour.

Parameters:
a - is the reference to the Agent object
mt - 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. The best practice is to have a MessageTemplate that matches the protocol slot; the static method createMessageTemplate might be usefull.
store - the DataStore for this protocol behaviour
Method Detail

prepareResponse

protected ACLMessage prepareResponse(ACLMessage cfp)
                              throws NotUnderstoodException,
                                     RefuseException
Deprecated. Use handleCfp() instead

NotUnderstoodException
RefuseException

prepareResultNotification

protected ACLMessage prepareResultNotification(ACLMessage cfp,
                                               ACLMessage propose,
                                               ACLMessage accept)
                                        throws FailureException
Deprecated. Use handleAcceptProposal() instead.

FailureException

registerPrepareResponse

public void registerPrepareResponse(Behaviour b)
Deprecated. Use registerHandleCfp() instead.


registerPrepareResultNotification

public void registerPrepareResultNotification(Behaviour b)
Deprecated. Use registerHandleAcceptProposal() instead.


createMessageTemplate

public static MessageTemplate createMessageTemplate(java.lang.String iprotocol)
This static method can be used to set the proper message Template (based on the interaction protocol and the performative) to be passed to the constructor of this behaviour.

See Also:
FIPANames.InteractionProtocol


JADE