unsw.cse.mica.agent
Interface Agent

All Superinterfaces:
MessageHandler
All Known Implementing Classes:
Debugger, DefaultAgent, DefaultAgent2, GUIAgent, LogDebugger, MobMaker, MobMaker2, MobSpawner, ProxyAgent, TimerAgent

public interface Agent
extends MessageHandler

The Agent is one of the most important classes in the MICA architecture. In order to implement an Agent, the most important methods that need to be implemented are:

There are also two methods for getting and setting the agent transport, but these are usually implemented as trivial getters and setters for an AgentTransport

It is likely that the agent will make extensive use of the AgentTransport methods.

Author:
Waleed Kadous

Method Summary
 AgentTransport getTransport()
          Get the agents's current transport.
 void init(MicaProperties args)
          Start the agent.
 void setTransport(AgentTransport at)
          Set the agent's transport.
 void terminate()
          Terminate the agent.
 
Methods inherited from interface unsw.cse.mica.agent.MessageHandler
handleDeletedMob, handleNewMob, handleReplacedMob, handleTypeManagerChanged
 

Method Detail

setTransport

void setTransport(AgentTransport at)
Set the agent's transport.

This is usually called by the program setting up the agent after the agent is constructed -- it's a messy way of informing both agent and agentTransport of their existence. The usual pattern for initialisation of agents is:

Parameters:
at - The agent to call.

getTransport

AgentTransport getTransport()
Get the agents's current transport.

Returns:
The agent's current transport.

init

void init(MicaProperties args)
          throws MicaException
Start the agent.

This signals to the agent that it should start.

Note: This function should not block -- it should return in a relatively short period of time, so that other parts of the Agent startup program can continue. If necessary, start your own thread to do your bidding.

It is safe to assume that by the time init() is called, setTransport() has been called.

The usual contents of an init() method would be:

Parameters:
args - Additional arguments provided to the agent. If the agent is started from with the 'Runner' tool, the args array contains the values provided from within the runner's XML configuration file. Otherwise, the exact contents will depend on the calling method.
Throws:
MicaException

terminate

void terminate()
               throws MicaException
Terminate the agent.

The agent should perform any necessary cleaning up in preparation for the process shutting down. This will generally mean doing the reverse of whatever occurred within the init method.

The usual contents of the terminate method would be:

  • Disconnect from the blackboard through the transport (eg. at.disconnect())

Throws:
MicaException