Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.mit.media.hive.agent.hiveui
Class BaseUIAgentImpl  view BaseUIAgentImpl download BaseUIAgentImpl.java

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended byedu.mit.media.hive.agent.AgentImpl
                  extended byedu.mit.media.hive.agent.EventReceivingAgentImpl
                      extended byedu.mit.media.hive.agent.hiveui.BaseUIAgentImpl
All Implemented Interfaces:
edu.mit.media.hive.agent.Agent, edu.mit.media.hive.rdf.Describable, java.util.EventListener, edu.mit.media.hive.agent.EventReceivingAgent, java.rmi.Remote, edu.mit.media.hive.event.RemoteEventListener, java.io.Serializable
Direct Known Subclasses:
BaseGUIAgentImpl

public abstract class BaseUIAgentImpl
extends edu.mit.media.hive.agent.EventReceivingAgentImpl

the standard base class for all ui agents -- this class will handle the minimum amount of state maintainance, and it will also handles a lot of the communications to the agent monitoring agents todo list -- the ability to monitor less cells than the agent monitoring agent is monitoring -- this would require that we filter the information the agent monitoring agent is sending and we need to keep track of exactly who we are monitoring


Field Summary
protected  edu.mit.media.hive.support.AgentGraph ag
          our copy of the agent graph -- this graph is constructed from the differential information that we get from the agent monitoring agent -- do NOT modify this graph -- please only read it
protected  java.util.Hashtable agentAddresses
           
protected  edu.mit.media.hive.agent.cell.AgentMonitoringAgent ama
           
protected  java.util.Hashtable cellControlAgents
           
static java.lang.String changeMonitoringCellCmd
          The menu strings for the popup CellList menu
static java.lang.String changeShowCellAgentsCmd
           
static java.lang.String connectCmd
           
static java.lang.String[] defaultCellCmds
           
static java.lang.String[] defaultCmds
           
static java.lang.String disconnectAllCmd
          a helper function which will determine the names of the menu items that should go on the popup menu for each agent
static java.lang.String disconnectCmd
           
static java.lang.String killCellCmd
           
static java.lang.String killCmd
           
protected  edu.mit.media.hive.support.menu.TopMenu menu
           
protected  java.util.Vector monitoredCells
           
static java.lang.String moveCmd
           
static java.lang.String propertiesCmd
           
private  edu.mit.media.hive.support.SerializableImage unknownAgentIcon
          a helper function that will get the icon for a certain agent -- this will go pretty hardcore to get an image.
protected  java.util.Hashtable variablePropertyManipulators
          a mapping between agents and their BeanManipulators -- this way we do not need to go through reflection all those times
 
Fields inherited from class edu.mit.media.hive.agent.EventReceivingAgentImpl
agentSubscriptions
 
Fields inherited from class edu.mit.media.hive.agent.AgentImpl
AGENTKILLED, AGENTMOVED, agentThreadGroup, commandList, commands, description, icon, iconName, myCell, readyFlag, stopCode, timeToStop
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
BaseUIAgentImpl()
           
 
Method Summary
private  void addAgent(edu.mit.media.hive.agent.Agent a)
          this method is used internally to add another agent to the graph and then to cause the UI to update itself because this new agent has come onto the scene
private  void connectAgents(edu.mit.media.hive.agent.Agent s, edu.mit.media.hive.agent.Agent d)
          this method is used internally so we can create a connection between two agents
 boolean connectAgentsCommand(edu.mit.media.hive.agent.Agent s, edu.mit.media.hive.agent.Agent d)
          Call this to connect two agents together
protected  void constructMenus()
          a helper function that reads the RDF files and stuff and creates the default menus that we are going to use
 boolean createNewAgentCommand(java.lang.String name, edu.mit.media.hive.support.CellAddress ca)
          Call this to create an agent on a particular server
 boolean disconnectAgentAllCommand(edu.mit.media.hive.agent.Agent a)
          Call this to disconnect all the agents
private  void disconnectAgentFromAll(edu.mit.media.hive.agent.Agent a)
          this is another internal method to handle when an agent disconnects from all other agents -- this is not implemented as just a series of calls to disconnectAgents as an optimization
private  void disconnectAgents(edu.mit.media.hive.agent.Agent s, edu.mit.media.hive.agent.Agent d)
          this is an internal method to handle the disconnection of two agents
 boolean disconnectAgentsCommand(edu.mit.media.hive.agent.Agent s, edu.mit.media.hive.agent.Agent d)
          Call this to disconnect two agents
 void doBehavior()
          Do the basic behavior for an agent, the agent's main loop.
 void doLocalCleanup()
          get rid of all our active references
 void doLocalSetup()
          start the monitoring of our agent monitoring agent -- this will get our handle to it, and it will then start up an event stream to it.
 java.lang.Object getAccessibleVariable(edu.mit.media.hive.agent.Agent a, java.lang.String variableName)
          get the variable inside a certain agent
 java.lang.String[] getAccessibleVariableNames(edu.mit.media.hive.agent.Agent a)
          get the variable names for the agent configuration stuff
 java.lang.Class getAccessibleVariableType(edu.mit.media.hive.agent.Agent a, java.lang.String variableName)
          get the variable type for a certain varible in an agent
 edu.mit.media.hive.support.CellAddress getAgentAddress(edu.mit.media.hive.agent.Agent a)
          another helper to find out what cell this agent is sitting on -- check if this returns null! the worst case scenario will have this return null as the cell address.
 edu.mit.media.hive.support.SerializableImage getAgentIcon(edu.mit.media.hive.agent.Agent a)
           
 java.lang.String getAgentName(edu.mit.media.hive.agent.Agent a)
          another helper function -- this one gets the name of the agent so it can display it
 edu.mit.media.hive.support.CellAddress getCellAddress()
          Returns the cell the uiAgent is running on.
 java.lang.String[] getMenuNames(edu.mit.media.hive.agent.Agent a)
           
 java.util.Vector getMonitoredCells()
          get a vector of all the cells that we are monitoring.
private  edu.mit.media.hive.support.VariablePropertyManipulator getVariablePropertyManipulator(edu.mit.media.hive.agent.Agent a)
          helper function to get or create a variable property manipulator object
 boolean invokeCellMenuCommand(edu.mit.media.hive.support.CellAddress cell, java.lang.String command)
          a helper function to ask the UI to deal with a command for a cell (these are the commands that were returned out of the cell list popup menu)
 boolean invokeMenuCommand(edu.mit.media.hive.agent.Agent a, java.lang.String command)
          a helper function to ask the agent to deal with a command (these are the commands that were returned out of the popup menu)
 boolean killAgentCommand(edu.mit.media.hive.agent.Agent a)
          Call this to kill an agent
private  edu.mit.media.hive.support.menu.MenuFolder makeMenu(java.io.InputStream is, java.lang.String fname)
          helper function to create a menu from the input stream
private  edu.mit.media.hive.support.menu.MenuFolder makeMenu(org.w3c.dom.Node node)
          another helper function to create an agent menu from a Node
private  edu.mit.media.hive.support.menu.MenuFolder makeMenu(java.lang.String filename)
          helper function to make a menu from a filename
 void monitorCell(edu.mit.media.hive.support.CellAddress ca)
          start monitoring another cell.
 boolean moveAgentCommand(edu.mit.media.hive.agent.Agent a, edu.mit.media.hive.support.CellAddress ca)
          Call this to move an agent from one server to another one
 void notify(edu.mit.media.hive.event.HiveEvent event)
          handle the event stream as it comes in
private  boolean pingAddress(edu.mit.media.hive.support.CellAddress ca)
          a helper function for ourselves to ping a cell.
private  void removeAgent(edu.mit.media.hive.agent.Agent a)
          this method is used internally to remove an agent from the agent graph and then to cause the UI to update itself because this new agent has come onto the scene
abstract  void renderAgentMessage(edu.mit.media.hive.agent.Agent s, edu.mit.media.hive.agent.Agent d)
          this method needs to be implemented so agent messaging can be drawn
abstract  void renderCellReport(edu.mit.media.hive.event.cell.CellReportCellEvent report)
          this method needs to be implemented so the server reports go somwhere
abstract  void renderConnectAgents(edu.mit.media.hive.agent.Agent s, edu.mit.media.hive.agent.Agent d)
          a method which needs to be implemented -- when two agents connect, this method will be called.
abstract  void renderDisconnectAgents(edu.mit.media.hive.agent.Agent s, edu.mit.media.hive.agent.Agent d)
          a method which needs to be implemented -- when two agents disconnect, this method will be called to display the change to the screen
abstract  void renderDisconnectFromAll(edu.mit.media.hive.agent.Agent a, edu.mit.media.hive.agent.Agent[] incoming, edu.mit.media.hive.agent.Agent[] outgoing)
          this method needs to be implemented for when an agent disconnects from all
abstract  void renderNewAgent(edu.mit.media.hive.agent.Agent a)
          a method which needs to be implemented -- this means that another agent has arrived on the scene and it needs to be drawn to the UI
abstract  void renderRemoveAgent(edu.mit.media.hive.agent.Agent a, edu.mit.media.hive.support.CellAddress ca, edu.mit.media.hive.agent.Agent[] incoming, edu.mit.media.hive.agent.Agent[] outgoing)
          a method which needs to be implemented -- this means that an agent has been removed from the scene and this change needs to be rendered.
 java.lang.Object setAccessibleVariable(edu.mit.media.hive.agent.Agent a, java.lang.String variableName, java.lang.Object o)
          set a variable for a certain agent
 boolean shutdownCellCommand(edu.mit.media.hive.support.CellAddress ca)
          Call this to shutdown a server.
 void stopMonitoringCell(edu.mit.media.hive.support.CellAddress ca)
          stop monitoring another cell.
private  java.lang.String stripWhiteSpace(java.lang.String raw)
           
 
Methods inherited from class edu.mit.media.hive.agent.EventReceivingAgentImpl
connectTo, diePlease, disconnectFrom, disconnectFromAll, listAllIncomingConnections, notify, subscribeTo
 
Methods inherited from class edu.mit.media.hive.agent.AgentImpl
addActionCommand, blockUntilReady, configure, doBehaviour, getActionCommands, getCell, getComponentManagerShadow, getDescription, getIcon, getIconName, getName, getThreadGroup, invokeActionCommand, isReady, isTimeToStop, listAllOutgoingConnections, loadIcon, moveTo, onDying, onMoving, setCell, setDescription, setIconName, setIsReady, setThreadGroup, setTimeToStop, waitUntilDeath
 
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
 
Methods inherited from interface edu.mit.media.hive.agent.Agent
blockUntilReady, configure, getActionCommands, getCell, getDescription, getIcon, getName, invokeActionCommand, isReady, listAllOutgoingConnections
 
Methods inherited from interface edu.mit.media.hive.rdf.Describable
setDescription
 

Field Detail

ama

protected edu.mit.media.hive.agent.cell.AgentMonitoringAgent ama

cellControlAgents

protected java.util.Hashtable cellControlAgents

ag

protected edu.mit.media.hive.support.AgentGraph ag
our copy of the agent graph -- this graph is constructed from the differential information that we get from the agent monitoring agent -- do NOT modify this graph -- please only read it


monitoredCells

protected java.util.Vector monitoredCells

agentAddresses

protected java.util.Hashtable agentAddresses

variablePropertyManipulators

protected java.util.Hashtable variablePropertyManipulators
a mapping between agents and their BeanManipulators -- this way we do not need to go through reflection all those times


menu

protected edu.mit.media.hive.support.menu.TopMenu menu

disconnectAllCmd

public static final java.lang.String disconnectAllCmd
a helper function which will determine the names of the menu items that should go on the popup menu for each agent

See Also:
Constant Field Values

propertiesCmd

public static final java.lang.String propertiesCmd
See Also:
Constant Field Values

connectCmd

public static final java.lang.String connectCmd
See Also:
Constant Field Values

disconnectCmd

public static final java.lang.String disconnectCmd
See Also:
Constant Field Values

moveCmd

public static final java.lang.String moveCmd
See Also:
Constant Field Values

killCmd

public static final java.lang.String killCmd
See Also:
Constant Field Values

defaultCmds

public static final java.lang.String[] defaultCmds

changeMonitoringCellCmd

public static final java.lang.String changeMonitoringCellCmd
The menu strings for the popup CellList menu

See Also:
Constant Field Values

changeShowCellAgentsCmd

public static final java.lang.String changeShowCellAgentsCmd
See Also:
Constant Field Values

killCellCmd

public static final java.lang.String killCellCmd
See Also:
Constant Field Values

defaultCellCmds

public static final java.lang.String[] defaultCellCmds

unknownAgentIcon

private edu.mit.media.hive.support.SerializableImage unknownAgentIcon
a helper function that will get the icon for a certain agent -- this will go pretty hardcore to get an image. it will first query the agent monitoring agent for an image, if that fails it will ask the agent itself, and if that fails it will go and get a default icon to use

Constructor Detail

BaseUIAgentImpl

public BaseUIAgentImpl()
                throws java.rmi.RemoteException
Method Detail

getCellAddress

public edu.mit.media.hive.support.CellAddress getCellAddress()
Returns the cell the uiAgent is running on.


doLocalSetup

public void doLocalSetup()
start the monitoring of our agent monitoring agent -- this will get our handle to it, and it will then start up an event stream to it. right now it displays all the information the agnet monitoring agent has -- so if somebody else asks the agent monitoring agent to monitor another cell, all that information will be pushed through to the display


constructMenus

protected void constructMenus()
a helper function that reads the RDF files and stuff and creates the default menus that we are going to use


makeMenu

private edu.mit.media.hive.support.menu.MenuFolder makeMenu(java.lang.String filename)
helper function to make a menu from a filename


makeMenu

private edu.mit.media.hive.support.menu.MenuFolder makeMenu(java.io.InputStream is,
                                                            java.lang.String fname)
helper function to create a menu from the input stream


makeMenu

private edu.mit.media.hive.support.menu.MenuFolder makeMenu(org.w3c.dom.Node node)
another helper function to create an agent menu from a Node


stripWhiteSpace

private java.lang.String stripWhiteSpace(java.lang.String raw)

doBehavior

public void doBehavior()
Description copied from class: edu.mit.media.hive.agent.AgentImpl
Do the basic behavior for an agent, the agent's main loop. Override this to provide your particular agent's behavior. Note: the doBehavior loop should not exit. Please call waitUntilDeath() at the end of this method, this will prevent the Cell from believing this agent prematurely exited.


notify

public void notify(edu.mit.media.hive.event.HiveEvent event)
handle the event stream as it comes in


doLocalCleanup

public void doLocalCleanup()
get rid of all our active references


addAgent

private void addAgent(edu.mit.media.hive.agent.Agent a)
this method is used internally to add another agent to the graph and then to cause the UI to update itself because this new agent has come onto the scene


renderNewAgent

public abstract void renderNewAgent(edu.mit.media.hive.agent.Agent a)
a method which needs to be implemented -- this means that another agent has arrived on the scene and it needs to be drawn to the UI


removeAgent

private void removeAgent(edu.mit.media.hive.agent.Agent a)
this method is used internally to remove an agent from the agent graph and then to cause the UI to update itself because this new agent has come onto the scene


renderRemoveAgent

public abstract void renderRemoveAgent(edu.mit.media.hive.agent.Agent a,
                                       edu.mit.media.hive.support.CellAddress ca,
                                       edu.mit.media.hive.agent.Agent[] incoming,
                                       edu.mit.media.hive.agent.Agent[] outgoing)
a method which needs to be implemented -- this means that an agent has been removed from the scene and this change needs to be rendered. this method also includes a list of agents that this agent was connected to so we can remove those connections also


connectAgents

private void connectAgents(edu.mit.media.hive.agent.Agent s,
                           edu.mit.media.hive.agent.Agent d)
this method is used internally so we can create a connection between two agents


renderConnectAgents

public abstract void renderConnectAgents(edu.mit.media.hive.agent.Agent s,
                                         edu.mit.media.hive.agent.Agent d)
a method which needs to be implemented -- when two agents connect, this method will be called. the two agents should already be on the graph -- two agents should not need to be connected if they are not on the graph yet


disconnectAgents

private void disconnectAgents(edu.mit.media.hive.agent.Agent s,
                              edu.mit.media.hive.agent.Agent d)
this is an internal method to handle the disconnection of two agents


renderDisconnectAgents

public abstract void renderDisconnectAgents(edu.mit.media.hive.agent.Agent s,
                                            edu.mit.media.hive.agent.Agent d)
a method which needs to be implemented -- when two agents disconnect, this method will be called to display the change to the screen


disconnectAgentFromAll

private void disconnectAgentFromAll(edu.mit.media.hive.agent.Agent a)
this is another internal method to handle when an agent disconnects from all other agents -- this is not implemented as just a series of calls to disconnectAgents as an optimization


renderDisconnectFromAll

public abstract void renderDisconnectFromAll(edu.mit.media.hive.agent.Agent a,
                                             edu.mit.media.hive.agent.Agent[] incoming,
                                             edu.mit.media.hive.agent.Agent[] outgoing)
this method needs to be implemented for when an agent disconnects from all


renderAgentMessage

public abstract void renderAgentMessage(edu.mit.media.hive.agent.Agent s,
                                        edu.mit.media.hive.agent.Agent d)
this method needs to be implemented so agent messaging can be drawn


renderCellReport

public abstract void renderCellReport(edu.mit.media.hive.event.cell.CellReportCellEvent report)
this method needs to be implemented so the server reports go somwhere


getMonitoredCells

public java.util.Vector getMonitoredCells()
get a vector of all the cells that we are monitoring. this simply returns a vector we keep around saying which cells we are monitoring


monitorCell

public void monitorCell(edu.mit.media.hive.support.CellAddress ca)
                 throws edu.mit.media.hive.agent.cell.UnableToMonitorCellException
start monitoring another cell. the way this works is that when you call this method we will ask the agent monitoring agent to start monitoring anther cell. we will also request the server control agent from that cell and squirrel it away so we can use it


stopMonitoringCell

public void stopMonitoringCell(edu.mit.media.hive.support.CellAddress ca)
stop monitoring another cell. this just goes through and asks the ama to stop monitoring a certain cell, and it gets rid of the references to the server control agents


getMenuNames

public java.lang.String[] getMenuNames(edu.mit.media.hive.agent.Agent a)

invokeMenuCommand

public boolean invokeMenuCommand(edu.mit.media.hive.agent.Agent a,
                                 java.lang.String command)
a helper function to ask the agent to deal with a command (these are the commands that were returned out of the popup menu)


invokeCellMenuCommand

public boolean invokeCellMenuCommand(edu.mit.media.hive.support.CellAddress cell,
                                     java.lang.String command)
a helper function to ask the UI to deal with a command for a cell (these are the commands that were returned out of the cell list popup menu)


getAgentIcon

public edu.mit.media.hive.support.SerializableImage getAgentIcon(edu.mit.media.hive.agent.Agent a)

getAgentName

public java.lang.String getAgentName(edu.mit.media.hive.agent.Agent a)
another helper function -- this one gets the name of the agent so it can display it


getAgentAddress

public edu.mit.media.hive.support.CellAddress getAgentAddress(edu.mit.media.hive.agent.Agent a)
another helper to find out what cell this agent is sitting on -- check if this returns null! the worst case scenario will have this return null as the cell address. this will only happen in the case that the ama does not know this agent's cell address, and we can't talk to the agent


shutdownCellCommand

public boolean shutdownCellCommand(edu.mit.media.hive.support.CellAddress ca)
Call this to shutdown a server.


createNewAgentCommand

public boolean createNewAgentCommand(java.lang.String name,
                                     edu.mit.media.hive.support.CellAddress ca)
                              throws java.lang.ClassNotFoundException
Call this to create an agent on a particular server


killAgentCommand

public boolean killAgentCommand(edu.mit.media.hive.agent.Agent a)
Call this to kill an agent


moveAgentCommand

public boolean moveAgentCommand(edu.mit.media.hive.agent.Agent a,
                                edu.mit.media.hive.support.CellAddress ca)
Call this to move an agent from one server to another one


connectAgentsCommand

public boolean connectAgentsCommand(edu.mit.media.hive.agent.Agent s,
                                    edu.mit.media.hive.agent.Agent d)
Call this to connect two agents together


disconnectAgentsCommand

public boolean disconnectAgentsCommand(edu.mit.media.hive.agent.Agent s,
                                       edu.mit.media.hive.agent.Agent d)
Call this to disconnect two agents


disconnectAgentAllCommand

public boolean disconnectAgentAllCommand(edu.mit.media.hive.agent.Agent a)
Call this to disconnect all the agents


getVariablePropertyManipulator

private edu.mit.media.hive.support.VariablePropertyManipulator getVariablePropertyManipulator(edu.mit.media.hive.agent.Agent a)
helper function to get or create a variable property manipulator object


getAccessibleVariableNames

public java.lang.String[] getAccessibleVariableNames(edu.mit.media.hive.agent.Agent a)
get the variable names for the agent configuration stuff


getAccessibleVariableType

public java.lang.Class getAccessibleVariableType(edu.mit.media.hive.agent.Agent a,
                                                 java.lang.String variableName)
                                          throws edu.mit.media.hive.support.UnknownVariablePropertyName
get the variable type for a certain varible in an agent


getAccessibleVariable

public java.lang.Object getAccessibleVariable(edu.mit.media.hive.agent.Agent a,
                                              java.lang.String variableName)
                                       throws edu.mit.media.hive.support.UnknownVariablePropertyName
get the variable inside a certain agent


setAccessibleVariable

public java.lang.Object setAccessibleVariable(edu.mit.media.hive.agent.Agent a,
                                              java.lang.String variableName,
                                              java.lang.Object o)
                                       throws edu.mit.media.hive.support.UnknownVariablePropertyName
set a variable for a certain agent


pingAddress

private boolean pingAddress(edu.mit.media.hive.support.CellAddress ca)
a helper function for ourselves to ping a cell. this is useful to see if a cell unexpectidly went down -- and if it did, then we need to stop monitoring it