agentland.naming
Class TranslatorAgent
java.lang.Object
|
+--java.rmi.server.RemoteObject
|
+--java.rmi.server.RemoteServer
|
+--java.rmi.server.UnicastRemoteObject
|
+--metaglue.AgentAgent
|
+--agentland.util.GoodAgent
|
+--agentland.resource.ManagedAgent
|
+--agentland.naming.TranslatorAgent
- All Implemented Interfaces:
- Agent, Good, Managed, MetagluePrimitives, Remote, Serializable, Spy, Translator
- public class TranslatorAgent
- extends ManagedAgent
- implements Translator
Basic Implementation of a Translator
- See Also:
ManagedAgent
,
Translator
, Serialized Form
Methods inherited from class agentland.resource.ManagedAgent |
connect, getAlert, getNeed, isAvailable, isAvailable, reliesOn, reliesOn, replace, replace, request, request, request, requestAgent, requestAgent, resources, resourcesByAgentID, setNeed, tiedTo, yank, yank, yank |
Methods inherited from class agentland.util.GoodAgent |
addSpy, addSpy, alert, alertString, beep, error, getHistory, getHistoryElement, getPersistentMap, log, notify, removeSpy, removeSpy, resetHistory, safeRely, safeRely, safeRely, setNiceLogName, tell |
Methods inherited from class metaglue.AgentAgent |
addMonitor, alive, buildEHAFor, defrost, defrostAll, defrostBoolean, defrostInt, defrostString, fixAttribute, fixAttribute, freeze, freeze, freeze, freezeAll, freezeVar, getAgentID, getAttribute, getCatalog, getCatalogID, getDesignation, getFrozenVariables, getLogLevel, getMetaglueAgent, getMetaglueAgentID, getOccupation, getOldLogs, getProperties, getProxyHandlerClass, getSociety, installAPH, log, log, lookupClass, reliesOn, reliesOnSynch, removeAPHFromCatalog, removeFrozen, setFreezeName, setLogLevel, setLogName, shutdown, startAgent, startAgentOn, startAgentOn, startup, status, tiedTo, tiedTo, tiedTo, tiedTo, tieToDesignation, toString, whereAreYou |
Methods inherited from interface agentland.util.Spy |
tell |
names
protected PersistentMap names
engine
protected TranslatorEngine engine
TranslatorAgent
public TranslatorAgent()
throws RemoteException
addName
public boolean addName(Serializable thing,
Serializable name)
throws RemoteException
- Allows you to add a name to a thing
- Specified by:
addName
in interface Translator
- Returns:
- true by default, false if something went terribly wrong
addNames
public boolean addNames(Serializable thing,
Collection names)
throws RemoteException
- A convenience method -- allows you to add several names at once
- Specified by:
addNames
in interface Translator
- Returns:
- true if things went well, false if anything went wrong
removeName
public boolean removeName(Serializable thing,
Serializable name)
throws RemoteException
- Remove a name from the list of names for the thing
- Specified by:
removeName
in interface Translator
- Returns:
- true if the name was removed, false if the name was not
there or some other problem occured
getUniqueName
public Serializable getUniqueName(Serializable thing)
throws RemoteException
- Get the unique name for the thing in the scope of this agent
(all other things registered with this agent will be
considered.
- Specified by:
getUniqueName
in interface Translator
- Returns:
- the unique name or null if no unique name was found for
the thing
getUniqueName
public Serializable getUniqueName(Serializable thing,
Collection context)
throws RemoteException
- Find a unique name that distinguishes thing from stuff passed
in the collection
- Specified by:
getUniqueName
in interface Translator
- Returns:
- returns a unique name (there may be more than one) or
null if none could be found
getAllNames
public Collection getAllNames(Serializable thing)
throws RemoteException
- Finds all names for the thing.
- Specified by:
getAllNames
in interface Translator
- Returns:
- will return an Empty list if no names were found (never
null)
getAllNamesForThings
public Collection getAllNamesForThings(Collection things)
throws RemoteException
- Get all the names for all the things passed in as the argument
- Specified by:
getAllNamesForThings
in interface Translator
- Returns:
- will return an Empty list if no names were found (never
null)
removeThing
public boolean removeThing(Serializable thing)
throws RemoteException
- Remove all names for the thing
- Specified by:
removeThing
in interface Translator
- Returns:
- true of all went well, false if the thing was not found
or other trouble happened
resolveName
public Collection resolveName(Serializable name)
throws RemoteException
- Returns all things associated with the name
- Specified by:
resolveName
in interface Translator
- Returns:
- will return an Empty list if no names were found (never
null)
addChild
public boolean addChild(AgentID child,
boolean permanent)
throws RemoteException
- Adds a child resolver -- the child resolvers will be queried if
the name could not be resolved by this agent. Exact
specification of the behavior will come later.
- Specified by:
addChild
in interface Translator
- Parameters:
child
- the agent id of the child resovlerpermanent
- true if the association is to be made
permanent (i.e. frozen); false if this is a one-time deal- Returns:
- true if all went well, false if the child could not be
found or is not a resolver
removeChild
public boolean removeChild(AgentID child)
throws RemoteException
- Removes the child (if it was a permanent child, the removal
will be permanent)
- Specified by:
removeChild
in interface Translator
- Returns:
- true if the child was found and removed, false
otherwise
forgetAll
public boolean forgetAll()
throws RemoteException
- Tells the resolver to forget all of the name-thing bindings
- Specified by:
forgetAll
in interface Translator
- Returns:
- true; false if there is trouble or the process is
abandoned (I will probably pop up a window to ask for
confirmation so user can change his/her mind)
getAllNames
public Collection getAllNames()
throws RemoteException
- Returns all names of all things registered with this agent
- Specified by:
getAllNames
in interface Translator
getAllThings
public Collection getAllThings()
throws RemoteException
- Returns all things registered with this agent
- Specified by:
getAllThings
in interface Translator