|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectunsw.cse.mica.agent.transport.AbstractAgentProtocol
public abstract class AbstractAgentProtocol
Provides support for some of the Protocol functionality that is shared between all protocols.
This includes connection to MessageHandler
objects,
and synchronization of actions and action replies. The inner class Reply
is used as a
description of the result of an action for this purpose.
Nested Class Summary | |
---|---|
class |
AbstractAgentProtocol.Reply
An encapsulation of a reply from the blackboards in response to an action. |
Constructor Summary | |
---|---|
AbstractAgentProtocol()
|
Method Summary | |
---|---|
void |
deleteMob(java.lang.String mobName)
Delete a mob from the blackboard. |
TypeManager |
getTypeManager()
Request a Mob TypeManager. |
void |
handleDeletedMob(Mob mob)
handle a deletedMob message. |
void |
handleNewMob(Mob mob)
handle a new mob message. |
void |
handleReplacedMob(Mob oldMob,
Mob newMob)
handle a deletedMob message. |
void |
handleTypeManagerChanged()
handle a typeManagerChanged message. |
java.util.List |
mobSearch(java.lang.String micaQuery)
Finds all mobs meeting the criteria. |
Mob |
readMob(java.lang.String mobName)
Retrieve a mob by its name. |
void |
register(java.lang.String mobType)
Allows the agent to register for events of a particular mobType. |
void |
replaceMob(Mob mob)
Replace a mob on the blackboard. |
void |
setConnection(AgentConnection connection)
Tell the protocol which underlying connection to use |
void |
setMessageHandler(MessageHandler messageHandler)
Set the object to inform when new messages arrive from the blackboard |
void |
unregister(java.lang.String mobType)
Inform the blackboard that we are no longer interested in a particular type. |
java.lang.String |
writeMob(Mob mob)
Write a mob to the blackboard. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface unsw.cse.mica.agent.transport.AgentProtocol |
---|
isConnected |
Methods inherited from interface unsw.cse.mica.agent.AgentActions |
---|
connect, disconnect |
Constructor Detail |
---|
public AbstractAgentProtocol()
Method Detail |
---|
public void setMessageHandler(MessageHandler messageHandler)
AgentProtocol
setMessageHandler
in interface AgentProtocol
public void setConnection(AgentConnection connection)
AgentProtocol
setConnection
in interface AgentProtocol
public TypeManager getTypeManager() throws TransportException
AgentActions
getTypeManager
in interface AgentActions
TransportException
- if the agent was not connectedpublic void register(java.lang.String mobType) throws TransportException, ActionException
AgentActions
Registration tells the blackboard that the agent is interested in mobs of a particular type.
If the securirty policy allows, the agent will be informed when mobs of this type are written
to the blackboard (via its handleNewMob
method) or when mobs of this type are
deleted from the blackboard (via its handleDeletedMob
method).
register
in interface AgentActions
mobType
- The type we are interested in
TransportException
- if the agent was not connected
ActionException
- if the requested type is not known.public void unregister(java.lang.String mobType) throws TransportException, ActionException
AgentActions
unregister
in interface AgentActions
mobType
- The type that the agent is no longer interested in hearing about.
TransportException
- if the agent was not connected
ActionException
- if the agent was not connected or if the requested type is not known.public Mob readMob(java.lang.String mobName) throws TransportException, ActionException
AgentActions
readMob
in interface AgentActions
mobName
- the name of the Mob to retrieve.
TransportException
- if the agent was not connected
ActionException
- if the requested mob doesn't existpublic java.lang.String writeMob(Mob mob) throws TransportException
AgentActions
writeMob
in interface AgentActions
TransportException
- if the agent was not connectedpublic void replaceMob(Mob mob) throws TransportException, ActionException
AgentActions
replaceMob
in interface AgentActions
mob
- the mob to be written. The mob's name must be specified and indicates the name
of the mob that will be replaced. The mob's type is ignored as the previous type will be carried over.
TransportException
- if the agent was not connected
ActionException
- if no mob existed with the given namepublic void deleteMob(java.lang.String mobName) throws TransportException, ActionException
AgentActions
deleteMob
in interface AgentActions
mobName
- the name of the mob to remove.
TransportException
- if the agent was not connected
ActionException
- if the requested mob doesn't existpublic java.util.List mobSearch(java.lang.String micaQuery) throws TransportException, ActionException
AgentActions
mobSearch
in interface AgentActions
micaQuery
- A query in the MicaQL query language.
TransportException
- if the agent was not connected
ActionException
- if the query was invalidpublic void handleNewMob(Mob mob)
handleNewMob
in interface MessageHandler
mob
- the mob that has been written to the blackboardpublic void handleDeletedMob(Mob mob)
handleDeletedMob
in interface MessageHandler
mob
- the mob that has been deletedpublic void handleReplacedMob(Mob oldMob, Mob newMob)
handleReplacedMob
in interface MessageHandler
oldMob
- the old value of the mob (where the name is cleared)newMob
- the new value of the mobpublic void handleTypeManagerChanged()
handleTypeManagerChanged
in interface MessageHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |