jade.wrapper.gateway
Class GatewayAgent

java.lang.Object
  |
  +--jade.core.Agent
        |
        +--jade.wrapper.gateway.GatewayAgent
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable, Serializable

public class GatewayAgent
extends Agent

This agent is the gateway able to execute all commands requests received via JadeGateway.

JadeGateway enables two alternative ways to implement a gateway that allows non-JADE code to communicate with JADE agents.
The first one is to extend the GatewayAgent
The second one is to extend this GatewayBehaviour and add an instance of this Behaviour to your own agent that will have to function as a gateway (see its javadoc for reference).

Version:
$Date: 2005-11-10 10:37:54 +0100 (Thu, 10 Nov 2005) $ $Revision: 5819 $
Author:
Fabio Bellifemine, Telecom Italia LAB
See Also:
JadeGateway, GatewayBehaviour, Serialized Form

Nested Class Summary
 
Nested classes inherited from class jade.core.Agent
Agent.Interrupted
 
Constructor Summary
GatewayAgent()
           
 
Method Summary
protected  void processCommand(java.lang.Object command)
          subclasses may implement this method.
 void releaseCommand(java.lang.Object command)
          notify that the command has been processed and remove the command from the queue
protected  void setup()
          This protected method is an empty placeholder for application specific startup code.
 
Methods inherited from class jade.core.Agent
addBehaviour, afterClone, afterMove, beforeClone, beforeMove, blockingReceive, blockingReceive, blockingReceive, blockingReceive, changeStateTo, doActivate, doClone, doDelete, doMove, doSuspend, doWait, doWait, doWake, getAgentState, getAID, getAMS, getArguments, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getHap, getHelper, getLocalName, getName, getO2AObject, getProperty, getQueueSize, here, postMessage, putBack, putO2AObject, receive, receive, removeBehaviour, restore, restoreBufferedState, send, setEnabledO2ACommunication, setQueueSize, takeDown, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

GatewayAgent

public GatewayAgent()
Method Detail

processCommand

protected void processCommand(java.lang.Object command)
subclasses may implement this method. The method is called each time a request to process a command is received from the JSP Gateway.

The recommended pattern is the following implementation: if (c instanceof Command1) exexCommand1(c); else if (c instanceof Command2) exexCommand2(c);

REMIND THAT WHEN THE COMMAND HAS BEEN PROCESSED, YOU MUST CALL THE METHOD releaseCommand.
Sometimes, you might prefer launching a new Behaviour that processes this command and release the command just when the Behaviour terminates, i.e. in its onEnd() method.


releaseCommand

public final void releaseCommand(java.lang.Object command)
notify that the command has been processed and remove the command from the queue

Parameters:
command - is the same object that was passed in the processCommand method

setup

protected void setup()
Description copied from class: Agent
This protected method is an empty placeholder for application specific startup code. Agent developers can override it to provide necessary behaviour. When this method is called the agent has been already registered with the Agent Platform AMS and is able to send and receive messages. However, the agent execution model is still sequential and no behaviour scheduling is active yet. This method can be used for ordinary startup tasks such as DF registration, but is essential to add at least a Behaviour object to the agent, in order for it to be able to do anything.

Overrides:
setup in class Agent
See Also:
Agent.addBehaviour(Behaviour b), Behaviour


JADE