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:
- Implement a class that extends
FipaContractNetResponderBehaviour. This class must
implement 4 methods that are called by
FipaContractNetResponderBehaviour:
-
public ACLMessage handleCfpMessage(ACLMessage cfp) to
evaluate the cfp message received and to return an
ACLMessage to be sent in response
(propose, refuse or
not-understood). If null is returned,
then the cfp is ignored and the behaviour is reset and
start again waiting for cfp messages.
-
public ACLMessage handleAcceptProposalMessage(ACLMessage msg)
to evaluate the received accept-proposal message and to
return an ACLMessage to be sent back (inform
Done or failure).
-
public void handleRejectProposalMessage(ACLMessage msg) to
evaluate the received reject-proposal. After this
method, the protocol is reset and it restarts again.
-
public void handleOtherMessages(ACLMessage msg) to
handle all the other types of messages, eventually answering not-understood.
- Optionally, the programmer might override the
reset() method that is called to reset the behaviour
and wait for a new cfp message. In this case, remind to
call also super.reset() from within overridden
reset() version!
- create a new instance of this class and add it to the agent
calling
Agent.addBehaviour())
- Author:
- Fabio Bellifemine - CSELT
- See Also:
FipaContractNetInitiatorBehaviour, Serialized Form
|
Field Summary |
boolean |
finished
this variable should be set to true when the behaviour should
terminate |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
finished
public boolean finished
- this variable should be set to true when the behaviour should
terminate
FipaContractNetResponderBehaviour
public FipaContractNetResponderBehaviour(Agent a)
- Constructor of the class.
- Parameters:
a - is the pointer to the Agent class
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