Package jade.wrapper.gateway
Class GatewayAgent
- java.lang.Object
-
- jade.core.Agent
-
- jade.wrapper.gateway.GatewayAgent
-
- All Implemented Interfaces:
TimerListener,Serializable,Serializable,Runnable
public class GatewayAgent extends Agent
This agent is the gateway able to execute all commands requests received via JadeGateway.JadeGatewayenables two alternative ways to implement a gateway that allows non-JADE code to communicate with JADE agents.
The first one is to extend theGatewayAgent
The second one is to extend thisGatewayBehaviourand 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$ $Revision$
- Author:
- Fabio Bellifemine, Telecom Italia LAB
- See Also:
JadeGateway,GatewayBehaviour, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jade.core.Agent
Agent.Interrupted
-
-
Field Summary
-
Fields inherited from class jade.core.Agent
AP_ACTIVE, AP_DELETED, AP_IDLE, AP_INITIATED, AP_MAX, AP_MIN, AP_SUSPENDED, AP_WAITING, D_ACTIVE, D_MAX, D_MIN, D_RETIRED, D_SUSPENDED, D_UNKNOWN, MSG_QUEUE_CLASS
-
-
Constructor Summary
Constructors Constructor Description GatewayAgent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidprocessCommand(Object command)subclasses may implement this method.voidreleaseCommand(Object command)notify that the command has been processed and remove the command from the queueprotected voidsetup()This protected method is an empty placeholder for application specific startup code.protected voidtakeDown()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, clean, createMessageQueue, doActivate, doClone, doDelete, doMove, doSuspend, doTimeOut, doWait, doWait, doWake, getAgentState, getAID, getAID, getAMS, getArguments, getBehavioursCnt, getBootProperties, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getExecutedBehavioursCnt, getGenerateBehaviourEvents, getGenerateMessageEvents, getHap, getHelper, getLocalName, getName, getO2AInterface, getO2AObject, getPostedMessagesCnt, getProperty, getQueueSize, getReceivedMessagesCnt, getSentMessagesCnt, getState, here, isAlive, isRestarting, join, notifyChangeBehaviourState, notifyRestarted, postMessage, putBack, putO2AObject, receive, receive, receive, registerO2AInterface, removeBehaviour, removeTimer, restartLater, restoreBufferedState, restoreFields, run, send, setArguments, setEnabledO2ACommunication, setGenerateBehaviourEvents, setGenerateMessageEvents, setO2AManager, setQueueSize, waitUntilStarted, write
-
-
-
-
Method Detail
-
processCommand
protected void processCommand(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:
REMIND THAT WHEN THE COMMAND HAS BEEN PROCESSED, YOU MUST CALL THE METHODif (c instanceof Command1) exexCommand1(c); else if (c instanceof Command2) exexCommand2(c);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 itsonEnd()method.
-
releaseCommand
public final void releaseCommand(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:AgentThis 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 aBehaviourobject to the agent, in order for it to be able to do anything.- Overrides:
setupin classAgent- See Also:
Agent.addBehaviour(Behaviour b),Behaviour
-
takeDown
protected void takeDown()
Description copied from class:AgentThis 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.
-
-