jade.proto
Class FipaQueryResponderBehaviour

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

public abstract class FipaQueryResponderBehaviour
extends SimpleBehaviour

Behaviour class for fipa-query Responder role. This abstract class implements the fipa-query interaction protocol. The behaviour is cyclic so it remains active forever. Its usage is the following: A class must be instantiated that extends this one. This new class must implement the method handleQueryMessage(). The instantiated class must then be added to the Agent object by using the method Agent.addBehaviour()

Author:
Fabio Bellifemine - CSELT
See Also:
Serialized Form

Inner classes inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
 
Field Summary
 boolean finished
          This variable must be set to true in order to finish the behaviour and remove it from the agent's behaviours.
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent
 
Constructor Summary
FipaQueryResponderBehaviour(Agent a)
          Constructor.
FipaQueryResponderBehaviour(Agent a, MessageTemplate mt)
          Constructor.
 
Method Summary
 void action()
          This final method actually implements the procotol.
 boolean done()
          This method checks whether this behaviour has finished or not.
abstract  ACLMessage handleQueryMessage(ACLMessage msg)
          This abstract method must be implemented by all sub-classes.
 void reset()
          This method allows to reset the behaviour.
 
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 must be set to true in order to finish the behaviour and remove it from the agent's behaviours.
Constructor Detail

FipaQueryResponderBehaviour

public FipaQueryResponderBehaviour(Agent a)
Constructor.
Parameters:
a - is the Agent that runs the behaviour.

FipaQueryResponderBehaviour

public FipaQueryResponderBehaviour(Agent a,
                                   MessageTemplate mt)
Constructor.
Parameters:
a - is the Agent that runs the behaviour.
mt - is the MessageTemplate to filter the messages to be consumed by this behaviour.
Method Detail

reset

public void reset()
This method allows to reset the behaviour.
Overrides:
reset in class SimpleBehaviour

done

public boolean done()
This method checks whether this behaviour has finished or not.
Returns:
true if this behaviour has completed its task, false otherwise.
Overrides:
done in class Behaviour

action

public final void action()
This final method actually implements the procotol. It cannot be overridden by subclasses.
Overrides:
action in class Behaviour

handleQueryMessage

public abstract ACLMessage handleQueryMessage(ACLMessage msg)
This abstract method must be implemented by all sub-classes. The method is called whenever a new query-if or query-ref message arrives.
Parameters:
msg - is the received message.
Returns:
the method must return the ACLMessage to be sent as a reply. In particular, the ACLMessage must have valid type (i.e. it must be failure or inform or refuse or not-understood) and valid message content.