jade.wrapper.gateway
Class GatewayAgent
java.lang.Object
jade.core.Agent
jade.wrapper.gateway.GatewayAgent
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Runnable
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: 2010-01-26 17:27:22 +0100 (mar, 26 gen 2010) $ $Revision: 6253 $
- Author:
- Fabio Bellifemine, Telecom Italia LAB
- See Also:
JadeGateway,
GatewayBehaviour,
Serialized Form
|
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. |
protected void |
takeDown()
This protected method is an empty placeholder for application
specific cleanup code. |
| Methods inherited from class jade.core.Agent |
addBehaviour, afterClone, afterMove, beforeClone, beforeMove, blockingReceive, blockingReceive, blockingReceive, blockingReceive, changeStateTo, createMessageQueue, doActivate, doClone, doDelete, doMove, doSuspend, doWait, doWait, doWake, getAgentState, getAID, getAMS, getArguments, getBootProperties, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getHap, getHelper, getLocalName, getName, getO2AObject, getProperty, getQueueSize, here, isRestarting, postMessage, putBack, putO2AObject, receive, receive, removeBehaviour, restore, restoreBufferedState, send, setEnabledO2ACommunication, setO2AManager, setQueueSize, 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 |
GatewayAgent
public GatewayAgent()
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
takeDown
protected void takeDown()
- Description copied from class:
Agent
- This protected method is an empty placeholder for application
specific cleanup code. Agent developers can override it to
provide necessary behaviour. When this method is called the agent
has not deregistered itself with the Agent Platform AMS
and is still able to exchange messages with other
agents. However, no behaviour scheduling is active anymore and
the Agent Platform Life Cycle state is already set to
deleted.
This method can be used for ordinary cleanup tasks such as
DF deregistration, but explicit removal of all agent
behaviours is not needed.
- Overrides:
takeDown in class Agent
These are the official JADE API. For these API backward compatibility is guaranteed accross JADE versions