com.agentfactory.platform.core
Class Agent

java.lang.Object
  extended by java.util.Observable
      extended by com.agentfactory.platform.core.Agent
All Implemented Interfaces:
java.util.Observer

public abstract class Agent
extends java.util.Observable
implements java.util.Observer

This class represents the embodiment of an agent within the AgentFactory runtime environment. Memebers include the agents name and various objects used by the AF platform's services. This class is abstract and must be instantiated for a given agent oriented programming language. A number of abstract methods are defined, each of these will have to be made concrete to provide the logical elements of a successful agent implementation. There is an arguement that some of the meta information contained here could be contained in the agent's own mental state. For example, the agent's beliefs could easily include information about the agent's name and required services. Rather than holding that information in the mental state, we hold it here. We do this because: (1) it cuts down on the information that needs to be reasoned about by the agent; (2) it removes the need to enforece the use of specific self knowledge actuators; (3) since this information is meta information about the state of the agent implementation, it is subalbe to store the information out of the agent's mental state. TODO - robertr - 13-Aug-2004 - Code review on migration.


Field Summary
static int ACTIVE
          FIPA ACTIVE STATE
 AgentPlatform agentPlatform
          The AF Platform on which the agent is running.
protected  java.util.Vector args
          The arguements supplied to the agent interpreter
protected  FIPAMessageQueue fipaMessageQueue
          A Queue of FIPA compliant messages.
static int INITIATED
          FIPA INITIATED STATE
 java.lang.String name
          The agent's name.
protected  int state
          Indicate the state of the agent.
static int SUSPENDED
          FIPA SUSPENDED STATE
static int TERMINATED
          FIPA TERMINATED STATE
static int TERMINATING
           
protected  int timeSlice
          The amount of time that the agent has for execution...
static int TRANSIT
          FIPA TRANSIT STATE
static int WAITING
          FIPA WAITING STATE
 
Constructor Summary
Agent(java.lang.String name, java.lang.String inType, AgentPlatform platform, java.util.Vector arguments)
          The main constructor for the Agent class.
 
Method Summary
 void addAgentID(AgentID id)
          Methods concerned with the Agent's Addressbook.
 boolean bindToService(java.lang.String serviceID)
          this method attempts to bind the agent to a specified service.
 void changeAIDName(java.lang.String inName)
          Change the AID Name.
 boolean containsBoundServiceByName(java.lang.String serviceName)
           
abstract  void endOfTimeSlice()
           
abstract  void execute()
           
 AgentID getAgentID()
           
 AgentID getAgentID(java.lang.String inName)
          Retrives the AgentID associated with the given name.
 java.util.Collection getAgentIDs()
           
 AgentPlatform getAgentPlatform()
          Get a handle to the AgentPlatform on which this agent is running
 java.util.Vector getAvailableMTSServices()
          Return the services available.
 java.util.Enumeration getBoundServices()
          Get the services that the agent is acutally bound to on this platform.
 FIPAMessageQueue getMessageQueue()
          Get the agent's message queuee
 java.lang.String getName()
          Get the agent's name.
 PlatformService getService(java.lang.String name)
           
 int getState()
          Get the State of the Agent Interperter.
 int getTimeSlice()
          Get the current time slice
abstract  java.lang.String getType()
           
abstract  void initialise(java.lang.String content)
          Called directly by the ScriptHandler class, this method is used to initialized a given type of agent.
abstract  void kill()
           
 void metaRegistration()
          Perform meta registration to activate FIPA type services.
 void notify(java.lang.String message)
          OBSERVER METHODS
 void removeAgentID(java.lang.String inName)
          Remove an agent ID from the agent's addressbook
 void resume()
           
 void setState(int state)
          Set the state of the agent interperter.
 void setTimeSlice(int timeSlice)
          Set the current time slice
abstract  void step()
           
 void suspend()
           
abstract  void terminate()
           
 java.lang.String toString()
           
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INITIATED

public static final int INITIATED
FIPA INITIATED STATE

See Also:
Constant Field Values

ACTIVE

public static final int ACTIVE
FIPA ACTIVE STATE

See Also:
Constant Field Values

WAITING

public static final int WAITING
FIPA WAITING STATE

See Also:
Constant Field Values

SUSPENDED

public static final int SUSPENDED
FIPA SUSPENDED STATE

See Also:
Constant Field Values

TRANSIT

public static final int TRANSIT
FIPA TRANSIT STATE

See Also:
Constant Field Values

TERMINATED

public static final int TERMINATED
FIPA TERMINATED STATE

See Also:
Constant Field Values

TERMINATING

public static final int TERMINATING
See Also:
Constant Field Values

state

protected int state
Indicate the state of the agent. The state can only be in one of the states explicitly defined above.


timeSlice

protected int timeSlice
The amount of time that the agent has for execution...


name

public java.lang.String name
The agent's name.


fipaMessageQueue

protected FIPAMessageQueue fipaMessageQueue
A Queue of FIPA compliant messages.


agentPlatform

public AgentPlatform agentPlatform
The AF Platform on which the agent is running.


args

protected java.util.Vector args
The arguements supplied to the agent interpreter

Constructor Detail

Agent

public Agent(java.lang.String name,
             java.lang.String inType,
             AgentPlatform platform,
             java.util.Vector arguments)
      throws AgentConfigurationException
The main constructor for the Agent class. Agent Classes should subclass this method, calling this super constructor and initialising their own state.

Parameters:
inName - - A String object that hods the given name of an agent
inType - - A String object that holds the type of the agent
inAgentPlatform - - An AgentPlatform objet that is running this agent interpreter.
inArguements - - A Vector object containing any arguements supplied to the interpreter. These will have been defined in the platform configuration file and are all String objects.
Throws:
AgentConfigurationException - - Thrown if there were any problems instantiating the agent instance.
Method Detail

metaRegistration

public void metaRegistration()
Perform meta registration to activate FIPA type services. This method is called by the agent platform following construction of the agent object.


setState

public void setState(int state)
Set the state of the agent interperter.

Parameters:
state - - The state to which the agent is to be set.

getState

public int getState()
Get the State of the Agent Interperter.

Returns:
one of the valid fipa states (specified as constants above)

getMessageQueue

public FIPAMessageQueue getMessageQueue()
Get the agent's message queuee

Returns:
FIPAMessageQueue - the agent's unique message queue.

bindToService

public boolean bindToService(java.lang.String serviceID)
this method attempts to bind the agent to a specified service. The return value indicates the success or failure of the binding attempt.

Parameters:
serviceID - the id of the service that the agent is to attempt to bind to
Returns:
true if the agent binds to the service, false otherwise#

getAvailableMTSServices

public java.util.Vector getAvailableMTSServices()
Return the services available.

Returns:
Vector the services that the agent needs and are available on the current platform.

getBoundServices

public java.util.Enumeration getBoundServices()
Get the services that the agent is acutally bound to on this platform.

Returns:
Enumeration - the services that the agent needs and are available on the current platform.

containsBoundServiceByName

public boolean containsBoundServiceByName(java.lang.String serviceName)

getService

public PlatformService getService(java.lang.String name)

addAgentID

public void addAgentID(AgentID id)
Methods concerned with the Agent's Addressbook. This method allows the addition of agent-identifiers to the agents' internal address list.

Parameters:
id - an AgentID

getAgentID

public AgentID getAgentID(java.lang.String inName)
Retrives the AgentID associated with the given name.

Parameters:
inName - the name of the agent whose ID is required.
Returns:
an AgentID

removeAgentID

public void removeAgentID(java.lang.String inName)
Remove an agent ID from the agent's addressbook

Parameters:
inName - The name of the agent that is to be removed from the addressbook.

changeAIDName

public void changeAIDName(java.lang.String inName)
Change the AID Name.

Parameters:
inName -

getAgentID

public AgentID getAgentID()

getAgentIDs

public java.util.Collection getAgentIDs()

getName

public java.lang.String getName()
Get the agent's name.

Returns:
String - The agent's name.

getAgentPlatform

public AgentPlatform getAgentPlatform()
Get a handle to the AgentPlatform on which this agent is running

Returns:
AgentPlatform

getTimeSlice

public int getTimeSlice()
Get the current time slice


setTimeSlice

public void setTimeSlice(int timeSlice)
Set the current time slice

Parameters:
timeSlice - the new time slice value

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

notify

public void notify(java.lang.String message)
OBSERVER METHODS


suspend

public void suspend()

resume

public void resume()

kill

public abstract void kill()

step

public abstract void step()

terminate

public abstract void terminate()

getType

public abstract java.lang.String getType()

endOfTimeSlice

public abstract void endOfTimeSlice()

execute

public abstract void execute()

initialise

public abstract void initialise(java.lang.String content)
Called directly by the ScriptHandler class, this method is used to initialized a given type of agent.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object