Class Agent

java.lang.Object
  |
  +--Agent

public class Agent
extends java.lang.Object


Field Summary
static java.util.Hashtable AgentCharacteristics
          A hashtable for Agent characteristics, ie AgentName, NickName, AgentHost, ANSHost, ANSName, MatchMaker, Broker, Keywords, Capabilities, DatabaseType, ProxyAgent
 CommunicateWithANS ansComm
           
protected  AgentWindow gui
          A link to the current Agent Window.
static java.util.Hashtable userHash
          A hashtable for the user to save persistent information
 MonitoredThreadGroup userThreadGroup
          A monitored Thread Group for the user to use
 
Constructor Summary
Agent()
          Properly starts up the agent, making decisions and filling in data based on command line values and defaults.
 
Method Summary
 void addDebugSwitch(java.lang.String type, boolean on)
          Adds a debug switch to the current list
 void addTaskTemplate(java.lang.String file)
           
 void Debug(DebugMsgCell Message)
          Adds a debug message to the queue to be printed.
 void DebugAgent(java.lang.String Message)
          Prints out a debug string from "AGENT"
 void exit()
          Unregisters from the ANS and actually exits.
 int getActionResSize()
           
 LinkedListQ getAgenda()
           
 int getAgendaSize()
           
 java.lang.String getAgentHost()
           
 java.lang.String getAgentName()
           
 Plan getagentPlan()
           
 int getAgentPlanSize()
           
 int getAgentPort()
           
 java.lang.String getANSHost()
           
 int getANSPort()
           
 java.lang.String getARAName()
          Gets the name of the current ARA.
 int getDebugMsgsQueueSize()
           
 int getDebugSwitchSize()
           
 int getIncomingQueueSize()
           
 MsgOutput getMsgOutput()
           
 java.lang.String getName()
           
 LinkedListQ getObjectives()
           
 int getObjectivesSize()
           
 java.util.Hashtable getPending()
           
 int getPendingSize()
           
 LinkedListQ getSchdQ()
           
 int getSchdQSize()
           
 int getSendQSize()
           
 LinkedListQ getTaskQueue()
           
 int getTaskQueueSize()
           
 java.util.Hashtable getTasks()
           
 int getTaskTemplatesSize()
           
 TraceTable getTraceTable()
          Returns the trace table currently stored.
 int getWITQSize()
           
 void initialize()
          Starts up all the internal DECAF threads
 boolean isLogging()
           
 boolean isTracing()
          Returns a boolean to tell wether tracing is on or off.
static void main(java.lang.String[] args)
          Stores the command line arguments in a static variable and creates a new agent.
 java.lang.String parseCommandLine(java.lang.String x)
          Returns the argument on the command line after x.
 java.lang.String parseCommandLine(java.lang.String x, boolean isSwitch)
          Parses the command line for x.
 int Qsize()
           
 boolean registerWithANS(java.lang.String x, int y)
          Registers with an Agent Name Server.
 java.lang.Object removeFromPending(java.lang.Object key)
          Removes an object from the pending hashtable and returns it.
 void runStartupTask()
          Sends ou the startup task for the agent.
 void send(KQMLmsg kqml)
          Sends the given KQML object.
 void send(java.lang.String message)
          Sends the given String message
 void sendError(KQMLmsg k, java.lang.String error)
          Sends an error message.
 void sendLocal(KQMLmsg k)
          Sends the given message to itself.
 void sendMessages()
          Sends all the messages in the SendQ
 void sendNow(java.lang.String message)
          Actually performs the task of sending a message.
 void setAgent(java.lang.String Name, java.lang.String Host, int Port, java.lang.String file)
          Synchronizes the internal agent variables to those set elsewhere.
 void setAns(java.lang.String Name, int Port)
          Syncs the internal ANS variables with ones set elsewhere
 void setARAName(java.lang.String name)
          Sets the name of the ARA
 void setTaskTemplate(java.lang.String file)
           
 void shutdownAgent()
          Sends the shutdown task to the agent and then exits when done.
 void size()
           
 int startListening(int port)
          Creates a socket for the agent to listen to.
 void startLogging(java.lang.String logFile)
          Turns logging on replacing the given file.
 void startTrace(java.lang.String taskName, int instances, boolean stop)
          Starts the appropriate trace variables and intializes the data structures.
 void stopListening()
          Stops listeneing to the current port and cleans up
 void stopLogging()
          Stops logging
 void stopTrace()
          Stops the trace and returns the data.
 void unregister()
          Unregisters with the ANS
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userHash

public static java.util.Hashtable userHash
A hashtable for the user to save persistent information


AgentCharacteristics

public static java.util.Hashtable AgentCharacteristics
A hashtable for Agent characteristics, ie AgentName, NickName, AgentHost, ANSHost, ANSName, MatchMaker, Broker, Keywords, Capabilities, DatabaseType, ProxyAgent


gui

protected AgentWindow gui
A link to the current Agent Window. Can be null.


ansComm

public CommunicateWithANS ansComm

userThreadGroup

public MonitoredThreadGroup userThreadGroup
A monitored Thread Group for the user to use

Constructor Detail

Agent

public Agent()
Properly starts up the agent, making decisions and filling in data based on command line values and defaults.

Method Detail

parseCommandLine

public java.lang.String parseCommandLine(java.lang.String x)
Returns the argument on the command line after x. Provides support for simplified calls and backwards compatibility.

Parameters:
x - The string to look for. Ex: "-agn"
Returns:
A string containing the word after x.

parseCommandLine

public java.lang.String parseCommandLine(java.lang.String x,
                                         boolean isSwitch)
Parses the command line for x.

Parameters:
x - The string to look for. Ex: "-anh"
isSwitch - If true then the return will be "true" and if not found "false"
Returns:
A String containing either the word after x, "true", or "false"

removeFromPending

public java.lang.Object removeFromPending(java.lang.Object key)
Removes an object from the pending hashtable and returns it.


startListening

public int startListening(int port)
Creates a socket for the agent to listen to.


registerWithANS

public boolean registerWithANS(java.lang.String x,
                               int y)
Registers with an Agent Name Server.

Parameters:
x - The host address of the new name server.
y - The port for the name server.

startLogging

public void startLogging(java.lang.String logFile)
Turns logging on replacing the given file.


stopLogging

public void stopLogging()
Stops logging


isLogging

public boolean isLogging()

setTaskTemplate

public void setTaskTemplate(java.lang.String file)

addTaskTemplate

public void addTaskTemplate(java.lang.String file)

setAgent

public void setAgent(java.lang.String Name,
                     java.lang.String Host,
                     int Port,
                     java.lang.String file)
Synchronizes the internal agent variables to those set elsewhere.


setAns

public void setAns(java.lang.String Name,
                   int Port)
Syncs the internal ANS variables with ones set elsewhere


getARAName

public java.lang.String getARAName()
Gets the name of the current ARA.


setARAName

public void setARAName(java.lang.String name)
Sets the name of the ARA


addDebugSwitch

public void addDebugSwitch(java.lang.String type,
                           boolean on)
Adds a debug switch to the current list


initialize

public void initialize()
Starts up all the internal DECAF threads


runStartupTask

public void runStartupTask()
Sends ou the startup task for the agent.


stopListening

public void stopListening()
Stops listeneing to the current port and cleans up


unregister

public void unregister()
Unregisters with the ANS


sendLocal

public void sendLocal(KQMLmsg k)
Sends the given message to itself.


sendError

public void sendError(KQMLmsg k,
                      java.lang.String error)
Sends an error message.


sendMessages

public void sendMessages()
Sends all the messages in the SendQ


send

public void send(java.lang.String message)
Sends the given String message


send

public void send(KQMLmsg kqml)
Sends the given KQML object.


sendNow

public void sendNow(java.lang.String message)
Actually performs the task of sending a message.


startTrace

public void startTrace(java.lang.String taskName,
                       int instances,
                       boolean stop)
Starts the appropriate trace variables and intializes the data structures.

Parameters:
taskName - The name of task to trace.

stopTrace

public void stopTrace()
Stops the trace and returns the data.


isTracing

public boolean isTracing()
Returns a boolean to tell wether tracing is on or off.


getTraceTable

public TraceTable getTraceTable()
Returns the trace table currently stored.


Debug

public void Debug(DebugMsgCell Message)
Adds a debug message to the queue to be printed.


DebugAgent

public void DebugAgent(java.lang.String Message)
Prints out a debug string from "AGENT"


shutdownAgent

public void shutdownAgent()
Sends the shutdown task to the agent and then exits when done.


exit

public void exit()
Unregisters from the ANS and actually exits.


main

public static void main(java.lang.String[] args)
Stores the command line arguments in a static variable and creates a new agent.


size

public void size()

Qsize

public int Qsize()

getDebugMsgsQueueSize

public int getDebugMsgsQueueSize()

getTaskQueueSize

public int getTaskQueueSize()

getSchdQSize

public int getSchdQSize()

getWITQSize

public int getWITQSize()

getObjectivesSize

public int getObjectivesSize()

getActionResSize

public int getActionResSize()

getAgendaSize

public int getAgendaSize()

getPendingSize

public int getPendingSize()

getIncomingQueueSize

public int getIncomingQueueSize()

getTaskTemplatesSize

public int getTaskTemplatesSize()

getAgentPlanSize

public int getAgentPlanSize()

getDebugSwitchSize

public int getDebugSwitchSize()

getSendQSize

public int getSendQSize()

getTasks

public java.util.Hashtable getTasks()

getMsgOutput

public MsgOutput getMsgOutput()

getTaskQueue

public LinkedListQ getTaskQueue()

getAgenda

public LinkedListQ getAgenda()

getSchdQ

public LinkedListQ getSchdQ()

getObjectives

public LinkedListQ getObjectives()

getagentPlan

public Plan getagentPlan()

getPending

public java.util.Hashtable getPending()

getAgentHost

public java.lang.String getAgentHost()

getAgentName

public java.lang.String getAgentName()

getName

public java.lang.String getName()

getAgentPort

public int getAgentPort()

getANSHost

public java.lang.String getANSHost()

getANSPort

public int getANSPort()