public abstract class GatewayBehaviour extends CyclicBehaviour
JadeGatewayenables two alternative ways to implement a gateway that allows non-JADE code to communicate with JADE agents.
GatewayAgent(see its javadoc for reference).
GatewayBehaviourand add an instance of this Behaviour to your own agent that will have to function as a gateway.
|Constructor and Description|
|Modifier and Type||Method and Description|
Runs the behaviour.
This method is just an empty placeholder for subclasses.
subclasses must implement this method.
notify that the command has been processed and remove the command from the queue
block, block, getAgent, getBehaviourName, getDataStore, getParent, isRunnable, onStart, restart, root, setAgent, setBehaviourName, setDataStore
public void action()
Behavioursubclasses to perform ordinary behaviour duty. An agent schedules its behaviours calling their
action()method; since all the behaviours belonging to the same agent are scheduled cooperatively, this method must not enter in an endless loop and should return as soon as possible to preserve agent responsiveness. To split a long and slow task into smaller section, recursive behaviour aggregation may be used.
protected abstract void processCommand(java.lang.Object command)
The recommended pattern is the following implementation:
if (c instanceof Command1)
else if (c instanceof Command2)
releaseCommand. Sometimes, you might prefer launching a new Behaviour that asynchronously processes this command and release the command just when the Behaviour terminates, i.e. in its
public final void releaseCommand(java.lang.Object command)
command- is the same object that was passed in the processCommand method
public int onEnd()
onEndis called after the behaviour has been removed from the pool of behaviours to be executed by an agent. Therefore calling
reset()is not sufficient to cyclically repeat the task represented by this
Behaviour. In order to achieve that, this
Behaviourmust be added again to the agent (using
myAgent.addBehaviour(this)). The same applies to in the case of a
Behaviourthat is a child of a