jade.proto
Class FipaQueryInitiatorBehaviour

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

public abstract class FipaQueryInitiatorBehaviour
extends SimpleBehaviour

This abstract behaviour implements the Fipa Query Interaction Protocol from the point of view of the agent initiating the protocol, that is the agent that sends the query-ref/query-if to a set of agents. In order to use correctly this behaviour, the programmer should do the following:

Author:
Fabio Bellifemine - CSELT S.p.A
See Also:
Serialized Form

Inner classes inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
 
Field Summary
protected  ACLMessage queryMsg
          This is the query-refMsg sent in the first state of the protocol
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent
 
Constructor Summary
FipaQueryInitiatorBehaviour(Agent a, ACLMessage msg)
          constructor of the behaviour.
FipaQueryInitiatorBehaviour(Agent a, ACLMessage msg, java.util.List responders)
          constructor of the behaviour.
 
Method Summary
 void action()
          action method of the behaviour.
 boolean done()
           
abstract  void handleInformMessages(java.util.Vector messages)
          After having sent the queryMsg messages, the protocol waits for the maximum timeout specified in those messages (reply-by parameter), or until all the answers are received.
abstract  void handleOtherMessages(ACLMessage msg)
          This method must be implemented by all subclasses.
 
Methods inherited from class jade.core.behaviours.SimpleBehaviour
reset
 
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

queryMsg

protected ACLMessage queryMsg
This is the query-refMsg sent in the first state of the protocol
Constructor Detail

FipaQueryInitiatorBehaviour

public FipaQueryInitiatorBehaviour(Agent a,
                                   ACLMessage msg,
                                   java.util.List responders)
constructor of the behaviour.
Parameters:
a - is the current agent. The public variable Agent myAgent contains then the pointer to the agent class. A common usage of this variable is to cast it to the actual type of Agent class and use the methods of the extended class. For instance appointments = (AppointmentAgent)myAgent.getAppointments()
msg - is the Query message to be sent (notice that the performative must be set to QUERY-IF or QUERY-REF
responders - is the group of agents (i.e. a List of AID) to which the query must be sent

FipaQueryInitiatorBehaviour

public FipaQueryInitiatorBehaviour(Agent a,
                                   ACLMessage msg)
constructor of the behaviour. In this case the set of agents to which the message is sent is exactly the receivers set in the passed ACLMessage.
See Also:
FipaQueryInitiatorBehaviour(Agent , ACLMessage , List )
Method Detail

action

public final void action()
action method of the behaviour. This method cannot be overriden by subclasses because it implements the actual FipaQuery protocol
Overrides:
action in class Behaviour

done

public boolean done()
Overrides:
done in class Behaviour

handleOtherMessages

public abstract void handleOtherMessages(ACLMessage msg)
This method must be implemented by all subclasses. After having sent the query-ref message, the base class calls this method everytime a new message arrives that is not an inform message. The method should react to this message in an implementation-dependent way. The instruction finished=true; should be executed to finish the query 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

handleInformMessages

public abstract void handleInformMessages(java.util.Vector messages)
After having sent the queryMsg messages, the protocol waits for the maximum timeout specified in those messages (reply-by parameter), or until all the answers are received. If no reply-by parameter was set, an infinite timeout is used, instead. After this timeout, this method is called to react to all the received INFORM messages. Notice that the method might be called even when the timeout is expired but no INFORM message is yet arrived; in such a case the size of the Vectorparameter is 0. Therefore, this method is always called to handle the last state of the protocol. The condition messages.size()==0 allows to discriminate between timeout elapsed / all responders have sent an answer (not necessarily an INFORM answer!).
Parameters:
messages - is the Vector of ACLMessage received so far