Class JavaAgent.context.AgentContext
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaAgent.context.AgentContext

java.lang.Object
   |
   +----JavaAgent.context.AgentContext

public class AgentContext
extends Object
implements ContextInterface
Abstract class which implements the ContextInterface and provides an execution environment for an Agent. This class also creates a CommInterface and optionally an AgentFrame GUI. Execution can take place as either a standalone process or via instantiation within an existing Java VM (e.g Applet execution). For standalone or applet execution, either a main() method or the applet init() method must instantiate and initialize the context object. Execution parameters which are bound at runtime are contained in a RuntimeParams object. Internal system messages are funneled back to the context via the addSystemMessage() method, if the message begins with the string "System stat:" then the message is being used to report some period system performance statistic and thus will not be added to the log file.


Copyright (c) 1995, H. Robert Frost, Stanford University. All rights reserved.

Copyright (c) 1996, H. Robert Frost, Enterprise Integration Technologies, Inc. All rights reserved.

RESTRICTED RIGHTS LEGEND: Use, duplication or disclosure by the Government is subject to restrictions as set forth in subparagraph(c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 and in similar clauses in the FAR and NASA FAR supplement.

This software is bound by the terms and conditions listed in the attached LICENSE file.



Variable Index

 o A
Agent which this context represents.
 o comm
Object which provides messaging functionality for the Agent.
 o comm_ready
Is the CommInterface ready to send messages?
 o frame
Agent GUI.
 o log_file
Name of the local log file for recording system messages.
 o params
Object which contains all parameters set at execution-time as either commandline args or applet parameters.

Constructor Index

 o AgentContext(RuntimeParams)
Constructor for AgentContext.

Method Index

 o addAgent()
Creates the Agent object.
 o addPanel(Panel)
Takes a panel created by the Agent and passed through the MessageOutput object and displays it in a new top-level window.
 o addSystemMessage(String)
Adds a system message.
 o addSystemMessage(String, Exception)
Adds a system message w/ optional exception.
 o commReady()
 o createCommInterface()
Creates a CommInterface for the Agent.
 o createGUI()
If the gui flag is set, creates an instance of AgentFrame to provide a interface to the user.
 o getAgent()
 o hasGUI()
 o initiateTermination()
Called to begin the termination process.
 o NonAgentMsg(Object)
Generic method for sending an Object message to some context-dependent non-agent destination (e.g.
 o parseArgs(String[])
Takes the array of command line arguments and creates a Hashtable of flag/token pairs.
 o resourceChanged(String)
Called when some Agent resource has changed.
 o setName(String)
Called when the Agent has changed its name.
 o terminate()
Called by the Agent to terminate the AgentContext.

Variables

 o params
  protected RuntimeParams params
Object which contains all parameters set at execution-time as either commandline args or applet parameters.
 o A
  protected Agent A
Agent which this context represents.
 o comm
  protected CommInterface comm
Object which provides messaging functionality for the Agent.
 o frame
  protected AgentFrame frame
Agent GUI.
 o log_file
  protected String log_file
Name of the local log file for recording system messages.
 o comm_ready
  protected boolean comm_ready
Is the CommInterface ready to send messages?

Constructors

 o AgentContext
  public AgentContext(RuntimeParams params)
Constructor for AgentContext. Sets the parameters and creates the CommInterface, represented Agent and possibly the AgentFrame.
Parameters:
params - Runtime parameters for the AgentContext.

Methods

 o createGUI
  protected void createGUI()
If the gui flag is set, creates an instance of AgentFrame to provide a interface to the user.
 o addAgent
  protected boolean addAgent()
Creates the Agent object. Must be overridden.
Returns:
Success of creation.
 o createCommInterface
  protected abstract void createCommInterface()
Creates a CommInterface for the Agent. Must be overridden.
 o getAgent
  protected Agent getAgent()
Returns:
Agent contained by context.
 o commReady
  public boolean commReady()
Returns:
Is the CommInterface functioning?
 o NonAgentMsg
  public void NonAgentMsg(Object message) throws NonAgentMsgException
Generic method for sending an Object message to some context-dependent non-agent destination (e.g. a legacy software application, database, etc.) Where this message is sent and how it is interpreted depends on the specific ContextInterface implementation. If no destination exists or some other problem occurs, a NonAgentMsgException will be thrown. Must be overridden.
 o hasGUI
  public boolean hasGUI()
Returns:
Does this context support a GUI?
 o initiateTermination
  public void initiateTermination()
Called to begin the termination process. Kills the gui then terminates the Agent.
 o terminate
  public void terminate()
Called by the Agent to terminate the AgentContext. This method is invoked after the agent has sent out its remove-address message. If it is a stand alone, calls the System.exit method, otherwise just disposes of the AgentFrame.
 o setName
  public void setName(String name)
Called when the Agent has changed its name. If stand alone, change the frame title.
Parameters:
name - The new name for the Agent.
 o resourceChanged
  public void resourceChanged(String type)
Called when some Agent resource has changed.
Parameters:
type - String identifying the type of the resource.
 o parseArgs
  protected static Hashtable parseArgs(String arg[])
Takes the array of command line arguments and creates a Hashtable of flag/token pairs.
Parameters:
arg - Command line arguments
Returns:
Hashtable of flag/token pairs.
 o addSystemMessage
  public void addSystemMessage(String message,
                               Exception e)
Adds a system message w/ optional exception.
Parameters:
message - The message to output.
e - Exception which generated the message, may be null.
 o addSystemMessage
  public void addSystemMessage(String message)
Adds a system message. If the Agent can do file IO, appends the message to a log file whose name is based on the Agent's name and creation time stamp.
Parameters:
message - The message to output.
 o addPanel
  public void addPanel(Panel p)
Takes a panel created by the Agent and passed through the MessageOutput object and displays it in a new top-level window.

All Packages  Class Hierarchy  This Package  Previous  Next  Index