jade.proto
Class FipaContractNetResponderBehaviour

java.lang.Object
  |
  +--jade.core.behaviours.Behaviour
        |
        +--jade.core.behaviours.SimpleBehaviour
              |
              +--jade.proto.FipaContractNetResponderBehaviour

public abstract class FipaContractNetResponderBehaviour
extends SimpleBehaviour

Behaviour class for fipa-contract-net Responder role. This abstract behaviour implements the fipa-contract-net interaction protocol from the point of view of a responder to a call for proposal (cfp) message. In order to use correctly this behaviour, the programmer should do the following:

Author:
Fabio Bellifemine - CSELT
See Also:
FipaContractNetInitiatorBehaviour, Serialized Form

Inner classes inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
 
Field Summary
 boolean finished
          this variable should be set to true when the behaviour should terminate
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent
 
Constructor Summary
FipaContractNetResponderBehaviour(Agent a)
          Constructor of the class.
 
Method Summary
 void action()
          Actual body of the behaviour.
 boolean done()
          This method checks whether this behaviour has finished its task.
abstract  ACLMessage handleAcceptProposalMessage(ACLMessage msg)
          This method is called when the accept-proposal message is received.
abstract  ACLMessage handleCfpMessage(ACLMessage cfp)
          This method is called when the cfp message is received.
abstract  void handleOtherMessages(ACLMessage msg)
          This method must be implemented by all subclasses.
abstract  void handleRejectProposalMessage(ACLMessage msg)
          This method is called when the reject-proposal message is received.
 void reset()
          This method is called to restart the protocol and wait again for a new call for proposal message.
 
Methods inherited from class jade.core.behaviours.Behaviour
block, block, handle, isRunnable, restart, root
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

finished

public boolean finished
this variable should be set to true when the behaviour should terminate
Constructor Detail

FipaContractNetResponderBehaviour

public FipaContractNetResponderBehaviour(Agent a)
Constructor of the class.
Parameters:
a - is the pointer to the Agent class
Method Detail

reset

public void reset()
This method is called to restart the protocol and wait again for a new call for proposal message. The method can be overriden by subclasses, but super.reset() should always be called.
Overrides:
reset in class SimpleBehaviour

done

public boolean done()
This method checks whether this behaviour has finished its task.
Returns:
true if the behaviour must be terminated, false otherwise.
Overrides:
done in class Behaviour

action

public final void action()
Actual body of the behaviour. It cannot be overriden.
Overrides:
action in class Behaviour

handleAcceptProposalMessage

public abstract ACLMessage handleAcceptProposalMessage(ACLMessage msg)
This method is called when the accept-proposal message is received.
Parameters:
msg - contains the received accept-proposal message.
Returns:
the ACLMessage to be sent as a response at the next state of the protocol.

handleRejectProposalMessage

public abstract void handleRejectProposalMessage(ACLMessage msg)
This method is called when the reject-proposal message is received. The method is also called when the timeout is elapsed. The protocol uses a default timeout, that is the class variable DEFAULTTIMEOUT; the :reply-by slot of the propose message overrides the default timeout. After the execution of this method the protocol is reset.
Parameters:
msg - contains the received reject-proposal message.

handleCfpMessage

public abstract ACLMessage handleCfpMessage(ACLMessage cfp)
This method is called when the cfp message is received.
Parameters:
msg - contains the received cfp message.
Returns:
the ACLMessage to be sent as a response at the next state of the protocol. If null, or different from propose, then the protocol is reset.

handleOtherMessages

public abstract void handleOtherMessages(ACLMessage msg)
This method must be implemented by all subclasses. After having sent the propose message, the base class calls this method everytime a new message arrives that is not an accept-proposal / reject-proposal message. The method should react to this message in an implementation-dependent way. The instruction finished=true; should be executed to finish the protocol. The class variable myAgent can be used to send messages or, after casting, to execute other implementation-dependent methods that belongs to the actual Agent object.
Parameters:
msg - is the ACLMessage just arrived