net.openai.ai.agent
Class Agent

java.lang.Object
  |
  +--net.openai.ai.agent.Agent
All Implemented Interfaces:
AgentConstants, java.io.Serializable
Direct Known Subclasses:
DaemonService, MobileAgent

public abstract class Agent
extends java.lang.Object
implements java.io.Serializable, AgentConstants

This class is the base class for all Agents. Even though this class implements the Serializable interface, it is not "mobile". If an instance of this class is sent to a host, it will not be automatically started like the MobileAgent class will. The reason that it does implement the Serializable interface is to retain inner data for when the MobileAgent migrates. If it did not, this data will be lost in the serialization process.

Version:
$Id: Agent.java,v 1.16 2002/02/26 14:56:46 thornhalo Exp $
History:
$Log: Agent.java,v $
Revision 1.16 2002/02/26 14:56:46 thornhalo
added the $Id:$ and $Log:$ CVS tags
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface net.openai.ai.agent.AgentConstants
AGENT_CONTINUE, AGENT_RETURN_TO_SENDER, AGENT_START
 
Constructor Summary
Agent()
          Constructs a new Agent.
 
Method Summary
protected  void displayMessage(java.lang.String msg)
          Displays a message.
protected abstract  void executeAgent()
          Implement this method to provide functionality for the Agent.
 java.lang.String getAgentDescription()
          Returns a description of the Agent.
 java.lang.String getAgentID()
          Returns the unique ID of that the Agent was assigned at its spawn time.
 long getAgentNumber()
          Returns the number of the agent as it was created on its source host.
protected  Daemon getDaemon()
          Returns the Daemon that started the Agent or received the agent from another host.
protected  java.io.PrintStream getLogStream()
          Returns the log stream for the local Daemon.
protected  int getRunState()
          Returns the run state for the Agent as defined in the AgentConstants interface.
 java.lang.String getShortDescription()
          Returns a short description of the Agent.
 java.lang.String getSpawnHostIP()
          Returns the IP of the host that the agent was spawned on.
 java.lang.String getSpawnHostName()
          Returns the name of the host that the agent was spawned on.
 long getSpawnTime()
          Returns the time the agent was spawned on the spawning host.
protected  void halt()
          Causes the Agent to halt execution.
 java.lang.String toString()
          Returns the Agent as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Agent

public Agent()
Constructs a new Agent.

Method Detail

getRunState

protected final int getRunState()
Returns the run state for the Agent as defined in the AgentConstants interface.

Returns:
The run state for the Agent.
See Also:
AgentConstants

executeAgent

protected abstract void executeAgent()
                              throws java.lang.Exception
Implement this method to provide functionality for the Agent.

java.lang.Exception

getDaemon

protected final Daemon getDaemon()
Returns the Daemon that started the Agent or received the agent from another host.

Returns:
The Daemon associated with the Agent.

getSpawnHostName

public final java.lang.String getSpawnHostName()
Returns the name of the host that the agent was spawned on.

Returns:
The name of the host that the agent was spawned on.

getSpawnHostIP

public final java.lang.String getSpawnHostIP()
Returns the IP of the host that the agent was spawned on.

Returns:
The IP of the host that the agent was spawned on.

getSpawnTime

public final long getSpawnTime()
Returns the time the agent was spawned on the spawning host.

Returns:
The spawning time in milliseconds.

getAgentNumber

public final long getAgentNumber()
Returns the number of the agent as it was created on its source host.

Returns:
The number of the agent as it was created on its source host.

getAgentID

public final java.lang.String getAgentID()
Returns the unique ID of that the Agent was assigned at its spawn time.

Returns:
The unique ID of the Agent.

getAgentDescription

public java.lang.String getAgentDescription()
Returns a description of the Agent.

Returns:
A description of the Agent.

getShortDescription

public java.lang.String getShortDescription()
Returns a short description of the Agent. This is most commonly a simple name.

Returns:
A short description of the Agent.

halt

protected void halt()
Causes the Agent to halt execution.


toString

public java.lang.String toString()
Returns the Agent as a String. The default value is the same as the getAgentID() method.

Overrides:
toString in class java.lang.Object
Returns:
The Agent as a String.

getLogStream

protected final java.io.PrintStream getLogStream()
Returns the log stream for the local Daemon.

Returns:
The log stream for the local Daemon.

displayMessage

protected final void displayMessage(java.lang.String msg)
Displays a message. This must be called from within the Agent's thread.

Parameters:
msg - The message to display.


Copyright - 2001 OpenAI Labs. All Rights Reserved.