Chapter 4. Agents

Table of Contents

Agent Functions
handleNewMob(Mob)
handleDeletedMob(Mob)
handleReplacedMob(Mob, Mob)
handleTypeManagerChanged()
setTransport(AgentTransport)
getTransport()
init(MicaProperties)
terminate()
Agent Transport
connect(String)
disconnect()
register(String)
unregister(String)
getTypeManager()
writeMob(Mob)
readMob(String)
deleteMob(String)
replaceMob(Mob)
mobSearch(String)
isConnected()
getAgentName()
setMessageHandler(MessageHandler)
synchronizedWriteMob(Mob, long)

In any system built utilising Mica the agents of the system are the most. Virtuall all functionality performed by the system and all interaction with users will be performed or mediated by one agent or another.

Agent Functions

For an agent to successfully work with Mica it needs to implement a number of specific functions. These functions are described in the following sections. So as not to restrict the agents capabilities how these agents implement the functions is left up to the agents developers.

The functions required for agents can be divided into two groups. The first four functions are used to receive mobs and information from the blackboard. The rest are used to standardise the manner in which agents are created and destroyed.

Some basic default implementations of these functions have been implemented in DefaultAgent, see the section called “DefaultAgents” for information about the implementation.

handleNewMob(Mob)

If any new mob is written to the blackboard and this agent is registered to receive it then this method will be called. For most agents this is the most important function as it determines how the agent is to respond to any received mobs.

handleDeletedMob(Mob)

When a mob is deleted from the blackboard and this agent is registered for its type then this method is called. This allows an agent to stay up to date with information on the blackboard.

handleReplacedMob(Mob, Mob)

When a mob is replaced and this agent is registered for its type then this method will be called.

handleTypeManagerChanged()

This method is called when the blackboard detects that its mob hierarchy has changed. Typically this only occurs when agents post mobs of unknown types which are then set to inherit from 'mob'.

setTransport(AgentTransport)

This method tells the agent what trasport it is to use to connect to the blackboard.

getTransport()

This method is used to get the trasport the agent is using to connect to the blackboard.

init(MicaProperties)

The standard process for creating and starting an agent is:

  1. Create the agent.

  2. Set the agent's transport.

  3. Initialise the agent.

This method is used to implement the third step in this process. Typically in this method an agent will connect to the blackboard and register for any mob type it is interested in.

Passed as an argument to the method is a set of parameters that may be used to configure the agent.

terminate()

This method tells the agent to shut itself down. Commonly this method will disconnect the agent from the blackboard.