|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.rmi.server.RemoteObject | +--java.rmi.server.RemoteServer | +--java.rmi.server.UnicastRemoteObject | +--metaglue.AgentAgent
Superclass of all Metaglue agents. Provides the Metaglue primitives: reliesOn, tiedTo, as well as a host of other useful items.
WARNING: It may be tempting to start up an agent instances using the standard "AgentAgent blah = new AgentAgent();". Don't. It will cause things to break in weird ways, and you will go quietly insane trying to debug why your agents think they are someone else. Use reliesOn() or something similar to bring up agents. Really.
Inner Class Summary | |
class |
AgentAgent.Attribute
Attribute class description |
Fields inherited from class java.rmi.server.RemoteObject |
ref |
Fields inherited from interface metaglue.Agent |
ALIVE, DIED, NO_METAGLUE, NOT_RUNNING, STARTING |
Constructor Summary | |
AgentAgent()
|
|
AgentAgent(AgentID agentID)
|
Method Summary | |
void |
addMonitor(AgentID monitor)
Add a log monitor that gets all the screen output. |
boolean |
alive()
|
protected Agent |
buildEHAFor(AgentID agentID,
Catalog catalog)
Make EHA for the agent agentID |
Object |
defrost(String var)
Defrosts an object to get its value from the icebox. |
Hashtable |
defrostAll()
Gets the variables and values stored in the icebox. |
boolean |
defrostBoolean(String var)
Defrosts a boolean value from the icebox. |
int |
defrostInt(String var)
Defrosts a boolean value from the icebox. |
String |
defrostString(String var)
Defrosts a string from the icebox. |
protected String |
fixAttribute(AgentID aid,
String attributeName)
|
protected String |
fixAttribute(AgentID aid,
String attributeName,
String specialMessage)
Allows you to fix an existing attribute (useful if you try to cast attribute to something and it fails) |
void |
freeze(String var,
boolean b)
`Freeze' a boolean value into the icebox. |
void |
freeze(String var,
int i)
`Freeze' an integer value into the icebox. |
void |
freeze(String var,
Serializable o)
`Freeze' an object into the icebox. |
void |
freezeAll()
A simple routine to freeze all the state of an object. |
void |
freezeVar(String var,
Object obj)
`Freeze' an object into the icebox. |
AgentID |
getAgentID()
|
String |
getAttribute(String attributeName)
Get attribute value for name. |
Catalog |
getCatalog()
|
CatalogID |
getCatalogID()
|
Object |
getDesignation()
|
Set |
getFrozenVariables()
Gets the set of variables stored in the icebox. |
int |
getLogLevel(int level)
|
MetaglueAgent |
getMetaglueAgent()
Gets the Metaglue Agent that loaded this agent |
AgentID |
getMetaglueAgentID()
Gets the Metaglue Agent ID that loaded this agent |
String |
getOccupation()
|
List |
getOldLogs()
Gets a list of all the old log messages |
Properties |
getProperties()
|
static Class |
getProxyHandlerClass()
Get the appropriate proxy handler for this class. |
String |
getSociety()
|
protected boolean |
installAPH(AgentID agentID)
Put an APH in the catalog. |
void |
log(int level,
String info)
Send a log message to the logging stream. |
void |
log(Object obj)
Send a log message to the logging stream. |
void |
log(String level,
String info)
Send a log message to the logging stream. |
protected Class |
lookupClass(String name)
Class to lookup class information given a class name. |
Agent |
reliesOn(AgentID agentID)
Major reliesOn call. |
Agent |
reliesOn(String occupation)
Ensures that the specified agent is running (starts if necessary). |
Agent |
reliesOn(String occupation,
Object designation)
Ensures that the specified agent is running (starts if necessary). |
Agent |
reliesOnSynch(AgentID agentID)
Synchronously rely on agentID. |
protected void |
removeAPHFromCatalog(AgentID agentID)
Remove an APH from the catalog. |
boolean |
removeFrozen(String var)
Remove a frozen object from the icebox. |
protected void |
setFreezeName(String name)
|
void |
setLogLevel(int level)
|
void |
setLogName(String n)
Sets a name for this agent that can be used while logging. |
void |
shutdown()
Changes the agent so that it cannot be found through the catalog or accept RMI calls. |
void |
startAgent(AgentID agentID)
|
void |
startAgentOn(AgentID theAgentID,
Metaglue metaglue,
boolean agent_previously_started,
Object[] parameters)
Start given agent on given metaglue agent. |
void |
startAgentOn(AgentID theAgentID,
String host)
Try to start agent on metaglue agent with given host for christian name, or, failing that, that host for a computer. |
void |
startup()
|
int |
status(AgentID agentID)
Determines the status of the described agent. |
void |
tiedTo(AgentID agentID)
Ensures that agent is running on the same MVM as a given agent Must be asserted in agent contructor. |
void |
tiedTo(AgentID theAgentID,
Object[] parameters)
Ensures that agent is running on the same MVM as a given agent. |
void |
tiedTo(InetAddress host,
Object[] parameters)
Ensures that agent is running on host (moving it there if necessary with given parameters). |
void |
tiedTo(String host)
|
protected String |
tieToDesignation()
If the designation string is a name of a known host, this method will tie this agent to the host named in designation. |
String |
toString()
|
InetAddress |
whereAreYou()
Returns the InetAddress of the machine where the agent is running |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
clone, exportObject, exportObject, exportObject, unexportObject |
Methods inherited from class java.rmi.server.RemoteServer |
getClientHost, getLog, setLog |
Methods inherited from class java.rmi.server.RemoteObject |
equals, getRef, hashCode, toStub |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public AgentAgent() throws RemoteException
public AgentAgent(AgentID agentID) throws RemoteException
Method Detail |
public MetaglueAgent getMetaglueAgent()
public AgentID getMetaglueAgentID() throws RemoteException
getMetaglueAgentID
in interface Agent
public Agent reliesOnSynch(AgentID agentID)
reliesOnSynch
in interface MetagluePrimitives
reliesOn(String)
protected void removeAPHFromCatalog(AgentID agentID)
public void startAgent(AgentID agentID)
public int status(AgentID agentID)
agentID
- AgentID of the target agent.reliesOn(AgentID)
public Agent reliesOn(String occupation)
agentID
- agentID of agent to startSpreadError
- some reliance could not spreadAgentNotDefinedError
- some part of the agent was not
completely definedNativityError
- an error occurred during the construction of
agent.InvalidArgumentException
- (runtime) agentID is nullpublic Agent reliesOn(String occupation, Object designation)
reliesOn(String)
protected boolean installAPH(AgentID agentID)
public static Class getProxyHandlerClass()
EHAInvocationHandler
protected Agent buildEHAFor(AgentID agentID, Catalog catalog)
agentID
- the agent to build the EHA for
If no EHA possible, then return null.public Agent reliesOn(AgentID agentID)
reliesOn(String)
protected Class lookupClass(String name) throws ClassNotFoundException
Class
valueLoadClass
public void tiedTo(AgentID agentID) throws RemoteException
AgentID
- agentID to tie agent to ("speech.AppGrammar");SpreadError
- some reliance could not spreadpublic void tiedTo(AgentID theAgentID, Object[] parameters) throws RemoteException
AgentID
- agentID to tie agent to ("speech.AppGrammar");parameters
- list of paramaters given when starting up agent.tiedTo(AgentID)
public void tiedTo(String host) throws RemoteException
public void tiedTo(InetAddress host, Object[] parameters) throws RemoteException
host
- host to tie agent to ("machine.ai.mit.edu",
"128.128.128.128")SpreadError
- some reliance could not spreadInvalidArgumentException
- (runtime) host is unknownprotected String tieToDesignation() throws RemoteException
public void startAgentOn(AgentID theAgentID, Metaglue metaglue, boolean agent_previously_started, Object[] parameters) throws RemoteException
public void startAgentOn(AgentID theAgentID, String host) throws RemoteException
host
- is either a christian name or a machine name.public Properties getProperties()
public String getAttribute(String attributeName)
AttributeError
- attribute database found corruptprotected String fixAttribute(AgentID aid, String attributeName)
protected String fixAttribute(AgentID aid, String attributeName, String specialMessage) throws MissingAttributeError
public String getSociety()
public String getOccupation()
public Object getDesignation()
public AgentID getAgentID()
getAgentID
in interface Agent
public CatalogID getCatalogID() throws RemoteException
public Catalog getCatalog() throws RemoteException
public boolean alive() throws RemoteException
alive
in interface Agent
public void shutdown() throws RemoteException
shutdown
in interface Agent
RemoteException
- if an error occurspublic void startup() throws RemoteException
startup
in interface Agent
public void freezeAll() throws RemoteException
public void freezeVar(String var, Object obj)
var
- The variable name to save under.obj
- The object being saved. This must satisfy Serializable.Icebox.freezeVar(java.lang.String, java.lang.String, java.lang.Object)
public boolean removeFrozen(String var)
var
- The variable name to remove.defrost(String)
,
freezeVar(String, Object)
public void freeze(String var, Serializable o)
var
- The variable name to save under.obj
- The object being saved.defrost(String)
,
CrystalOutputStream
public void freeze(String var, int i)
var
- The variable name to save under.i
- The object being saved.freeze(String, Serializable)
,
defrost(String)
,
CrystalOutputStream
public void freeze(String var, boolean b)
var
- The variable name to save under.b
- The object being saved.freeze(String, Serializable)
,
defrost(String)
,
CrystalOutputStream
protected void setFreezeName(String name)
public Object defrost(String var)
var
- The variable name to defrost.freezeVar(String, Object)
public boolean defrostBoolean(String var)
var
- The variable name to defrost.defrost(String)
public int defrostInt(String var)
var
- The variable name to defrost.defrost(String)
public String defrostString(String var)
var
- The variable name to defrost.defrost(String)
public Set getFrozenVariables()
freezeVar(String, Object)
,
defrost(String)
public Hashtable defrostAll() throws RemoteException
freezeVar(String, Object)
,
defrost(String)
public InetAddress whereAreYou() throws RemoteException
whereAreYou
in interface Agent
public void setLogName(String n)
n
- A string with the new log name in it.public void log(Object obj)
obj
- The object to log.log(int, String)
public void log(int level, String info)
level
- The log level.info
- The string to send to the log.LogStream
public void log(String level, String info)
level
- The log level, usually one of "INFO", "DEBUG",
"WARNING", "ERROR", or "CRITICAL". If it's unrecognized, the log
level will be "INFO".info
- The string to send to the log.log(int, String)
public void setLogLevel(int level)
public int getLogLevel(int level)
public void addMonitor(AgentID monitor) throws RemoteException
Agent
addMonitor
in interface Agent
public List getOldLogs()
Agent
getOldLogs
in interface Agent
public String toString()
toString
in class RemoteObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |