|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--jade.core.behaviours.Behaviour
|
+--jade.core.behaviours.SimpleBehaviour
|
+--jade.proto.FipaRequestInitiatorBehaviour
Behaviour class for fipa-request Initiator role.This abstract
behaviour implements the fipa-request interaction protocol from the point
of view of the agent initiating the protocol, that is the agent that sends the
request message to an agent.
In order to use correctly this behaviour, the programmer shoud do the following:
FipaRequestInitiatorBehaviour. This class
must implements five methods that are called by FipaRequestInitiatorBehaviour:protected handleAgree(ACLMessage msg) to handle the agree reply.
protected handleInform(ACLMessage msg) to handle the inform message received from
the peer agent.
protected handleNotUnderstood(ACLMessage msg) to handle the not-understood reply.
protected handleFailure(ACLMessage msg))to handle the failure reply.
protected handleRefuse(ACLMessage msg) to handle the refuse reply.
Agent.addBehaviour()
method.
The behaviour can be hot reset, calling one of the following method in one of the handle methods
other than from handleAgree:
reset() to simply restart the protocol with the same ACLMessage and MessageTemplate.
reset(ACLMessage request) to restart the protocol with a new ACLMessage;
reset(ACLMessage request, MessageTemplate template) to restart the protocol
with new ACLMessage and MessageTemplate.
public handleOtherMessages(ACLMessage reply)
in order to handle replies different from those stated by the protocol.
The method public long handleTimeOut() can be override to handle
the expiration of the timeout.
FipaRequestResponderBehaviour, Serialized Form| Inner classes inherited from class jade.core.behaviours.Behaviour |
Behaviour.RunnableChangedEvent |
| Field Summary | |
protected boolean |
finished
Use this protected variable to block the protocol in whatever state. |
| Fields inherited from class jade.core.behaviours.Behaviour |
myAgent,
myEvent,
NOTIFY_DOWN,
NOTIFY_UP,
parent |
| Constructor Summary | |
FipaRequestInitiatorBehaviour(Agent client,
ACLMessage request)
Constructor for this behaviour. |
|
FipaRequestInitiatorBehaviour(Agent client,
ACLMessage request,
MessageTemplate template)
Public constructor for this behaviour. |
|
| Method Summary | |
void |
action()
|
boolean |
done()
|
protected ACLMessage |
getRequest()
This method gives access to the request ACL message,
originally set by the class constructor. |
protected abstract void |
handleAgree(ACLMessage reply)
Abstract method to handle agree replies. |
protected abstract void |
handleFailure(ACLMessage reply)
Abstract method to handle failure
replies. |
protected abstract void |
handleInform(ACLMessage reply)
Abstract method to handle inform replies. |
protected abstract void |
handleNotUnderstood(ACLMessage reply)
Abstract method to handle not-understood
replies. |
protected void |
handleOtherMessages(ACLMessage reply)
This method can be override to handle other received messages different from those stated by the protocol. |
protected abstract void |
handleRefuse(ACLMessage reply)
Abstract method to handle refuse replies. |
long |
handleTimeout()
This method is called by the action method when the timeout set in the request message is expired. |
void |
reset()
This method resets this behaviour so that it restarts from the initial state of the protocol with the same request message. |
void |
reset(ACLMessage request)
This method resets this behaviour so that it restarts the protocol with another request message. |
void |
reset(ACLMessage request,
MessageTemplate template)
This method resets this behaviour so that it restarts the protocol with other request message and MessageTemplate |
| 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 |
protected boolean finished
| Constructor Detail |
public FipaRequestInitiatorBehaviour(Agent client,
ACLMessage request,
MessageTemplate template)
Behaviour object that sends a request ACL
message and calls user-defined methods to handle the different
kinds of reply expected whithin a fipa-request
interaction.client - The agent this behaviour belongs to, that embodies
Initiator role in this fipa-request
interaction.request - The ACLMessage object to be sent. When
passed to this constructor, the message type is set to
request and the :protocol slot is set to
fipa-request, so there's no need to set them before
calling the constructor. If present, :conversation-id
and :reply-with slots are used for interaction
labelling. Application programmer must ensure the following
properties of request parameter when calling this
constructor:
request has a valid :receiver slot value.
request has a valid :content slot value.
request has a valid :language slot value.
request has a valid :ontology slot value.
:receiver slot is actually used by this
behaviour to send the message to the destination agent (only one
receiver is supported by fipa-request protocol).template - A MessageTemplate object used to match
incoming replies. This behaviour automatically matches replies
according to message type and :protocol slot value;
also, :conversation-id and :reply-to slot
values are matched when corresponding slot values are present in
request parameter. This constructor argument can be
used to match additional fields, such as :language and
:ontology slots.
public FipaRequestInitiatorBehaviour(Agent client,
ACLMessage request)
| Method Detail |
public void reset()
public void reset(ACLMessage request)
request - updates request message to be sent.
public void reset(ACLMessage request,
MessageTemplate template)
request - update request message to be sent.template - a new MessageTemplate.protected ACLMessage getRequest()
request ACL message,
originally set by the class constructor.request message sent by this
behaviour.public boolean done()
public void action()
protected abstract void handleNotUnderstood(ACLMessage reply)
not-understood
replies. This method must be implemented by
FipaRequestInitiatorBehaviour subclasses to react to
not-understood messages from the peer agent.reply - The actual ACL message received. It is of
not-understood type and matches the conversation
template.protected abstract void handleRefuse(ACLMessage reply)
refuse replies. This method
must be implemented by FipaRequestInitiatorBehaviour
subclasses to react to refuse messages from the peer
agent.reply - The actual ACL message received. It is of
refuse type and matches the conversation
template.protected abstract void handleAgree(ACLMessage reply)
agree replies. This method
must be implemented by FipaRequestInitiatorBehaviour
subclasses to react to agree messages from the peer
agent.reply - The actual ACL message received. It is of
agree type and matches the conversation
template.protected abstract void handleFailure(ACLMessage reply)
failure
replies. This method must be implemented by
FipaRequestInitiatorBehaviour subclasses to react to
failure messages from the peer agent.reply - The actual ACL message received. It is of
failure type and matches the conversation
template.protected abstract void handleInform(ACLMessage reply)
inform replies. This method
must be implemented by FipaRequestInitiatorBehaviour
subclasses to react to inform messages from the peer
agent.reply - The actual ACL message received. It is of
inform type and matches the conversation
template.protected void handleOtherMessages(ACLMessage reply)
public long handleTimeout()
reset to restart the protocol with different message or template;
finished = true;
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||