    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class JavaAgent.context.AgentContext

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

public abstract 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.

##

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

##

AgentContext(RuntimeParams)
  Constructor for AgentContext.

##

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

##

params

     protected RuntimeParams params

  Object which contains all parameters set at execution-time as either commandline args or applet parameters.

A

     protected Agent A

  Agent which this context represents.

comm

     protected CommInterface comm

  Object which provides messaging functionality for the Agent.

frame

     protected AgentFrame frame

  Agent GUI.

log_file

     protected String log_file

  Name of the local log file for recording system messages.

comm_ready

     protected boolean comm_ready

  Is the CommInterface ready to send messages?

##

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.

##

createGUI

     protected void createGUI()

  If the gui flag is set, creates an instance of AgentFrame to provide a interface to the user.

addAgent

     protected boolean addAgent()

  Creates the Agent object. Must be overridden.

  Returns:
    Success of creation.

createCommInterface

     protected abstract void createCommInterface()

  Creates a CommInterface for the Agent. Must be overridden.

getAgent

     protected Agent getAgent()

  Returns:
    Agent contained by context.

commReady

     public boolean commReady()

  Returns:
    Is the CommInterface functioning?

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.

hasGUI

     public boolean hasGUI()

  Returns:
    Does this context support a GUI?

initiateTermination

     public void initiateTermination()

  Called to begin the termination process. Kills the gui then terminates the Agent.

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.

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.

resourceChanged

     public void resourceChanged(String type)

  Called when some Agent resource has changed.

  Parameters:
    type - String identifying the type of the resource.

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.

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.

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.

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