Class 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.

    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$ $Revision$
    Author:
    Fabio Bellifemine, Telecom Italia LAB
    See Also:
    JadeGateway, GatewayBehaviour, Serialized Form
    • Constructor Detail

      • GatewayAgent

        public GatewayAgent()
    • 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: 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​(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