agentland.util
Class NotifierAgent

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--metaglue.AgentAgent
                          |
                          +--agentland.util.NotifierAgent
Direct Known Subclasses:
CatalogAgent, LocalLogManagerAgent, WindowsWebBrowserAgent

public class NotifierAgent
extends AgentAgent
implements Notifier

 Modification History:
 =====================
 12/12/00 by MHC: We have fixed some race conditions that were breaking
 this.  They were triggered by agents adding themselves as spies from 
 their constructors while the secrets they were listening for were 
 generated by other agents.  
 05/30/00 by KZG: I have modified the Notifier to freeze its
 bindings every time they are changed. Now when the Notifier wakes
 up, it defrosts its bindings and tries to use them.

 

See Also:
Serialized Form

Inner classes inherited from class metaglue.AgentAgent
AgentAgent.Attribute
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface metaglue.Agent
ALIVE, DIED, NO_METAGLUE, NOT_RUNNING, STARTING
 
Constructor Summary
NotifierAgent()
           
NotifierAgent(AgentID agentID)
           
 
Method Summary
 void addSpy(AgentID spy, String noteType)
          This assumes the Spy implements the Spy interface.
 void addSpy(AgentID spyName, String callMethod, String noteType)
          The MAIN METHOD for adding spies.
 Iterator getNoteTypes()
           
 HashSet getNotifyTable(String noteType)
           
 void gossip(Secret the_secret)
          Does the same work as notify.
 void hack_notify(HashSet folks, Secret secret)
           
 Object lookupSpy(AgentID spyName)
          A simple lookup procedure to let spies call the reliesOn procedure when necessary.
 void notify(HashSet folks, Secret secret)
           
 void notify(Secret the_secret)
          This is what a source invokes to tell any watching spys what is going on.
 void passNotify(Secret secret)
          So we can chain notifiers together in big nets o fun.
 void putNotifyTable(String noteType, agentland.util.SpyRecord spy)
           
 void removeAllSpies()
          Clears all spies -- useful if you need to purge the frozen bindings...
 void removeNotifyTable(String noteType, agentland.util.SpyRecord spy)
           
 void removeSpy(AgentID spyName)
          Remove all entries for the given spy.
 void removeSpy(AgentID spy, String noteType)
          This assumes the spy implements the Spy interface.
 void removeSpy(AgentID spyName, String callMethod, String noteType)
          The MAIN METHOD for removing spys.
 void removeSpy(String spyName, String callMethod, String noteType)
           
 void removeSpy(String spyOcc, String spyDesig, String callMethod, String noteType)
           
 
Methods inherited from class metaglue.AgentAgent
addMonitor, alive, defrost, defrostAll, defrostBoolean, defrostInt, defrostString, fixAttribute, fixAttribute, freeze, freeze, freeze, freezeAll, freezeVar, getAgentID, getAttribute, getCatalog, getCatalogID, getDesignation, getFrozenVariables, getLogLevel, getMetaglueAgent, getMetaglueAgentID, getOccupation, getProperties, getSociety, log, log, log, obtainMetaglueAgent, obtainMetaglueAgent, obtainMetaglueAgentByName, reliesOn, reliesOn, reliesOn, reliesOnSynch, removeFrozen, replaceExceptionHandler, setFreezeName, setLogLevel, setLogName, shutdown, startAgent, startAgentOn, startAgentOn, startup, status, tiedTo, tiedTo, tiedTo, tiedTo, tieToDesignation, whereAreYou
 
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, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NotifierAgent

public NotifierAgent(AgentID agentID)
              throws RemoteException

NotifierAgent

public NotifierAgent()
              throws RemoteException
Method Detail

lookupSpy

public Object lookupSpy(AgentID spyName)
                 throws RemoteException
A simple lookup procedure to let spies call the reliesOn procedure when necessary.

getNotifyTable

public HashSet getNotifyTable(String noteType)

putNotifyTable

public void putNotifyTable(String noteType,
                           agentland.util.SpyRecord spy)

removeNotifyTable

public void removeNotifyTable(String noteType,
                              agentland.util.SpyRecord spy)

getNoteTypes

public Iterator getNoteTypes()
Returns:
list of all known note types.

addSpy

public void addSpy(AgentID spy,
                   String noteType)
Description copied from interface: Notifier
This assumes the Spy implements the Spy interface.
Specified by:
addSpy in interface Notifier

addSpy

public void addSpy(AgentID spyName,
                   String callMethod,
                   String noteType)
The MAIN METHOD for adding spies.
Specified by:
addSpy in interface Notifier
Tags copied from interface: Notifier
Parameters:
spyName - The spy to be found.
callMethod - A string specifying the method name to call when the requested notification occurs. The method should return void, and take two arguments; first, a String specifying the notification type, and second, another String with extra information. This is the same signature as the notify method in this class.
noteType - A simple string specifying the type of the notification. Any Secret with a name string which _begins_ with the passed notetype will be sent to the spy. So if a spy registers for Boogie events, then a Boogie.Down event will get shipped to the spy as well as strict Boogie events.
See Also:
AgentAgent.reliesOn(java.lang.String), Notifier.removeSpy(metaglue.AgentID, java.lang.String, java.lang.String), Notifier.notify(agentland.util.Secret)

removeSpy

public void removeSpy(AgentID spy,
                      String noteType)
Description copied from interface: Notifier
This assumes the spy implements the Spy interface.
Specified by:
removeSpy in interface Notifier

removeSpy

public void removeSpy(String spyName,
                      String callMethod,
                      String noteType)

removeSpy

public void removeSpy(String spyOcc,
                      String spyDesig,
                      String callMethod,
                      String noteType)

removeSpy

public void removeSpy(AgentID spyName,
                      String callMethod,
                      String noteType)
The MAIN METHOD for removing spys.
Specified by:
removeSpy in interface Notifier
Tags copied from interface: Notifier
Parameters:
spyName - A string specifiying the agent's class name.
callMethod - A string specifying the method name.
noteType - A string specifying the type of the notification.
See Also:
AgentAgent.reliesOn(java.lang.String), Notifier.addSpy(metaglue.AgentID, java.lang.String, java.lang.String), Notifier.notify(agentland.util.Secret)

removeSpy

public void removeSpy(AgentID spyName)
Remove all entries for the given spy.

removeAllSpies

public void removeAllSpies()
                    throws RemoteException
Clears all spies -- useful if you need to purge the frozen bindings...
Specified by:
removeAllSpies in interface Notifier

gossip

public void gossip(Secret the_secret)
            throws RemoteException
Description copied from interface: Notifier
Does the same work as notify.
Specified by:
gossip in interface Notifier
Tags copied from interface: Notifier
See Also:
Notifier.notify(Secret)

passNotify

public void passNotify(Secret secret)
                throws RemoteException
So we can chain notifiers together in big nets o fun. It calls notify if and only if the society of the secret sender is not the same as ours
Specified by:
passNotify in interface Notifier

notify

public void notify(Secret the_secret)
            throws RemoteException
This is what a source invokes to tell any watching spys what is going on. It does this with a new thread, so it is non-blocking.
Specified by:
notify in interface Notifier
Tags copied from interface: Notifier
Parameters:
secret - This is the Secret to pass to any registered Spy agents.

hack_notify

public void hack_notify(HashSet folks,
                        Secret secret)

notify

public void notify(HashSet folks,
                   Secret secret)