agentland.naming
Interface Translator

All Superinterfaces:
Agent, Good, Managed, Remote, Spy
All Known Implementing Classes:
TranslatorAgent

public interface Translator
extends Managed

I am convinced that we need a somewhat sophisticated name resolution scheme for our agents. This interface and the corresponding agent are an attempt to solve the problem. This system allows:

See Also:
Agent

Fields inherited from interface metaglue.Agent
ALIVE, DIED, NO_METAGLUE, NOT_RUNNING, STARTING
 
Method Summary
 boolean addChild(AgentID child, boolean permanent)
          Adds a child resolver -- the child resolvers will be queried if the name could not be resolved by this agent.
 boolean addName(Serializable thing, Serializable name)
          Allows you to add a name to a thing
 boolean addNames(Serializable thing, Collection names)
           
 boolean forgetAll()
          Tells the resolver to forget all of the name-thing bindings
 Collection getAllNames()
           
 Collection getAllNames(Serializable thing)
          Get all the names for the thing
 Collection getAllNamesForThings(Collection things)
          Get all the names for all the things passed in as the argument
 Collection getAllThings()
           
 Serializable getUniqueName(Serializable thing)
          Get the unique name for the thing
 Serializable getUniqueName(Serializable thing, Collection context)
           
 boolean removeChild(AgentID child)
          Removes the child (if it was a permanent child, the removal will be permanent)
 boolean removeName(Serializable thing, Serializable name)
          Remove a name from the list of alternative names for the thing
 boolean removeThing(Serializable thing)
          Remove all names for the thing
 Collection resolveName(Serializable name)
          Returns all things associated with the name
 
Methods inherited from interface agentland.resource.Managed
getNeed, replace, replace, resources, yank, yank
 
Methods inherited from interface agentland.util.Good
getHistory, getHistoryElement, resetHistory
 
Methods inherited from interface metaglue.Agent
addMonitor, alive, getAgentID, getMetaglueAgentID, getOldLogs, shutdown, startup, whereAreYou
 
Methods inherited from interface agentland.util.Spy
tell
 

Method Detail

addName

public boolean addName(Serializable thing,
                       Serializable name)
                throws RemoteException
Allows you to add a name to a thing
Returns:
true by default, false if something went terribly wrong

addNames

public boolean addNames(Serializable thing,
                        Collection names)
                 throws RemoteException

removeName

public boolean removeName(Serializable thing,
                          Serializable name)
                   throws RemoteException
Remove a name from the list of alternative names for the thing
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
Returns:
the unique name or null if no unique name was set for the thing

getUniqueName

public Serializable getUniqueName(Serializable thing,
                                  Collection context)
                           throws RemoteException

getAllNames

public Collection getAllNames(Serializable thing)
                       throws RemoteException
Get all the names for the thing
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
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
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
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.
Parameters:
child - the agent id of the child resovler
permanent - 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)
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
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

getAllThings

public Collection getAllThings()
                        throws RemoteException