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.SSResponder
                                |
                                +--jade.proto.SSContractNetResponder
All Implemented Interfaces:
Serializable, java.io.Serializable
Direct Known Subclasses:
ContractNetResponder

public class SSContractNetResponder
extends jade.proto.SSResponder

Single Session version of the Responder role in the Fipa-Contract-Net protocol.

Author:
Giovanni Caire - TILAB
See Also:
Serialized Form

Field Summary
 java.lang.String ACCEPT_PROPOSAL_KEY
          Key to retrieve from the DataStore of the behaviour the last received ACCEPT_PROPOSAL ACLMessage
 java.lang.String CFP_KEY
          Key to retrieve from the DataStore of the behaviour the last received CFP ACLMessage
static java.lang.String HANDLE_ACCEPT_PROPOSAL
           
static java.lang.String HANDLE_CFP
           
static java.lang.String HANDLE_REJECT_PROPOSAL
           
 java.lang.String INITIATION_KEY
          Key to retrieve from the DataStore of the behaviour the initiation ACLMessage that triggered this responder session
 java.lang.String PROPOSE_KEY
          Key to retrieve from the DataStore of the behaviour the last sent PROPOSE ACLMessage
 java.lang.String RECEIVED_KEY
          Key to retrieve from the DataStore of the behaviour the last received ACLMessage
 java.lang.String REJECT_PROPOSAL_KEY
          Key to retrieve from the DataStore of the behaviour the last received REJECT_PROPOSAL ACLMessage
 java.lang.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.
 
Fields inherited from class jade.core.behaviours.FSMBehaviour
currentName, lastStates
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent
 
Constructor Summary
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
protected  ACLMessage handleAcceptProposal(ACLMessage cfp, ACLMessage propose, ACLMessage accept)
          This method is called when an ACCEPT_PROPOSAL message is received from the initiator.
protected  ACLMessage handleCfp(ACLMessage cfp)
          This method is called to handle the initial CFP message.
protected  void handleOutOfSequence(ACLMessage msg)
          This method is called whenever a message is received that does not comply to the protocol rules.
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.
protected  void handleRejectProposal(ACLMessage cfp, ACLMessage propose, ACLMessage reject)
          This method is called when a REJECT_PROPOSAL message is received from the initiator.
 void registerHandleAcceptProposal(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_ACCEPT_PROPOSAL state.
 void registerHandleCfp(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_CFP state.
 void registerHandleOutOfSequence(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_OUT_OF_SEQ state.
 void registerHandleRejectProposal(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_REJECT_PROPOSAL state.
protected  void reinit()
          Re-initialize the internal state without performing a complete reset.
 void reset()
          Reset this behaviour.
 
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

CFP_KEY

public final java.lang.String CFP_KEY
Key to retrieve from the DataStore of the behaviour the last received CFP ACLMessage


PROPOSE_KEY

public final java.lang.String PROPOSE_KEY
Key to retrieve from the DataStore of the behaviour the last sent PROPOSE ACLMessage


ACCEPT_PROPOSAL_KEY

public final java.lang.String ACCEPT_PROPOSAL_KEY
Key to retrieve from the DataStore of the behaviour the last received ACCEPT_PROPOSAL ACLMessage


REJECT_PROPOSAL_KEY

public final java.lang.String REJECT_PROPOSAL_KEY
Key to retrieve from the DataStore of the behaviour the last received REJECT_PROPOSAL ACLMessage


HANDLE_CFP

public static final java.lang.String HANDLE_CFP
See Also:
Constant Field Values

HANDLE_ACCEPT_PROPOSAL

public static final java.lang.String HANDLE_ACCEPT_PROPOSAL
See Also:
Constant Field Values

HANDLE_REJECT_PROPOSAL

public static final java.lang.String HANDLE_REJECT_PROPOSAL
See Also:
Constant Field Values

INITIATION_KEY

public final java.lang.String INITIATION_KEY
Key to retrieve from the DataStore of the behaviour the initiation ACLMessage that triggered this responder session


RECEIVED_KEY

public final java.lang.String RECEIVED_KEY
Key to retrieve from the DataStore of the behaviour the last received ACLMessage


REPLY_KEY

public final java.lang.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.

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 defferent from 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 :content slot.
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 :content slot.
NotUnderstoodException - if the CFP content is not undrerstood. Throwing a NotUnderstoodException has the same effect as returning a NOT_UNDERSTOOD message, but automatically manages the :content slot.

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 :content slot.

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-by slot 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 defined Behaviour in the HANDLE_CFP state. This behaviour would override the homonymous method. This method also sets the data store of the registered Behaviour to the DataStore of this current behaviour.
The registered behaviour can retrieve the initial CFP message from the datastore at the CFP_KEY key.
It is responsibility of the registered behaviour to put the reply to be sent back to the initiator into the datastore at the REPLY_KEY key. 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 defined Behaviour in the HANDLE_ACCEPT_PROPOSAL state. This behaviour would override the homonymous method. This method also sets the data store of the registered Behaviour to the DataStore of this current behaviour.
The registered behaviour can retrieve the received ACCEPT_PROPOSAL message from the datastore at the ACCEPT_PROPOSAL_KEY key, the initial CFP message at the CFP_KEY and the previously sent PROPOSE message at the PROPOSE_KEY.
It is responsibility of the registered behaviour to put the reply to be sent back to the initiator into the datastore at the REPLY_KEY key.

Parameters:
b - the Behaviour that will handle this state

registerHandleRejectProposal

public void registerHandleRejectProposal(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_REJECT_PROPOSAL state. This behaviour would override the homonymous method. This method also sets the data store of the registered Behaviour to the DataStore of this current behaviour.
The registered behaviour can retrieve the received REJECT_PROPOSAL message from the datastore at the REJECT_PROPOSAL_KEY key, the initial CFP message at the CFP_KEY and the previously sent PROPOSE message at the PROPOSE_KEY.

Parameters:
b - the Behaviour that will handle this state

reinit

protected void reinit()
Re-initialize the internal state without performing a complete reset.

Overrides:
reinit in class jade.proto.SSResponder

handleOutOfSequence

protected void handleOutOfSequence(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:
msg - the received out-of-sequence message.

registerHandleOutOfSequence

public void registerHandleOutOfSequence(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_OUT_OF_SEQ state. This behaviour would override the homonymous method. This method also sets the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the out of sequence ACLMessage object received from the datastore at the RECEIVED_KEY key.

Parameters:
b - the Behaviour that will handle this state

reset

public void reset()
Reset this behaviour.

Overrides:
reset in class FSMBehaviour


JADE