|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Agent
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:
init
method.
terminate
method.
handleNewMob
method
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.
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 |
---|
void setTransport(AgentTransport at)
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:
AgentTransport
, providing the agent as a parameter.
AgentTransport
calls setTransport
on the agent it
was constructed with (usually as part of its constructor).
init()
on the agent.
at
- The agent to call.AgentTransport getTransport()
void init(MicaProperties args) throws MicaException
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:
at.connect("ThisAgent")
)
at.register("text")
)
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.
MicaException
void terminate() throws MicaException
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:
at.disconnect()
)
MicaException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |