cia.agent
Class PersonalAgent

java.lang.Object
  |
  +--cia.agent.PersonalAgent
Direct Known Subclasses:
AddressBookAgent, AgentPlace, AgentReceiver, AgentSender, ClusterControlAgent, CookieAgent, CookieAgentTester, MessageLogAgent, PersistentObjectSpace, PosMonitor, PosTestAgent, StringReverser, UserCommunicationAgent

public abstract class PersonalAgent
extends java.lang.Object
implements Agent

this class represents the abstract agent class. This must be the base class of all cia agents being located within an agent cluster.

Version:
0.1 99-04-28 09:30 illmann initial coding.
0.2 99-06-26 17:31 illmann getRole and removeRole use last part of classname.
0.3 99-07-10 16:44 illmann init won't be called by place but by personal agent.
Author:
Torsten Illmann
See Also:
AgentBusFactory

Field Summary
protected  boolean isDone
           
 
Constructor Summary
PersonalAgent()
          Creates the personal agent.
 
Method Summary
 void addRole(AgentRole role)
          adds an agent role to the agent, i.e. mobility role, control role.
 AgentBusFactory getAgentBusFactory()
          returns the agent bus factory
 AgentURL getAgentURL()
          returns the agents' url
 java.lang.String getName()
          returns the name of the agent.
 AgentRole getRole(java.lang.String name)
          returns a specific role of an agent.
 void init()
          adds the control role to the personal agent.
static void main(java.lang.String[] args)
          starts a new personal agent.
 boolean removeRole(java.lang.String name)
          removes a role from an agent.
 void run()
          implements the run method of the runnable interface.
 void setAgentBusFactory(AgentBusFactory abusFactory)
          sets the agent bus factory.
 void setAgentURL(AgentURL clusterURL)
          sets the agent url.
 void stop()
          stops the agent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isDone

protected boolean isDone
Constructor Detail

PersonalAgent

public PersonalAgent()
Creates the personal agent. Its name is built automatically from the classname.
Method Detail

getName

public java.lang.String getName()
returns the name of the agent. This is the class name of the agent.
Specified by:
getName in interface Agent
Returns:
agent name

getAgentURL

public AgentURL getAgentURL()
returns the agents' url
Specified by:
getAgentURL in interface Agent
Returns:
the agent url

getAgentBusFactory

public AgentBusFactory getAgentBusFactory()
returns the agent bus factory
Specified by:
getAgentBusFactory in interface Agent
Returns:
the agent bus factory

setAgentURL

public void setAgentURL(AgentURL clusterURL)
sets the agent url. The agent url is build of the url parameter and the agents' name, i.e. cia://first.last@cn:id/agent
Specified by:
setAgentURL in interface Agent
Parameters:
clusterURL - an agentURL; will be cut to the clusterURL

setAgentBusFactory

public void setAgentBusFactory(AgentBusFactory abusFactory)
sets the agent bus factory. The agent needs the factory to create channels.
Specified by:
setAgentBusFactory in interface Agent
Parameters:
abusFactory - the agent bus factory

addRole

public void addRole(AgentRole role)
adds an agent role to the agent, i.e. mobility role, control role. A role is a communication behavior for client agent to communicate with another agent in the agent cluster.

If a role has a specific interface, the agent programmer should hold the role in a member variable as well. Roles without specific interface can be applied dynamically by the cluster.

Specified by:
addRole in interface Agent
Parameters:
role - the role to be added.
See Also:
Agent.addRole(cia.agent.AgentRole)

getRole

public AgentRole getRole(java.lang.String name)
                  throws java.util.NoSuchElementException
returns a specific role of an agent.
Specified by:
getRole in interface Agent
Parameters:
name - (actually) the classname of the role.

removeRole

public boolean removeRole(java.lang.String name)
removes a role from an agent.
Specified by:
removeRole in interface Agent
Parameters:
name - (actually) the classname of the role.

init

public void init()
adds the control role to the personal agent.
Specified by:
init in interface Agent

run

public void run()
implements the run method of the runnable interface.

stop

public void stop()
          throws java.lang.IllegalMonitorStateException
stops the agent.
Specified by:
stop in interface Agent

main

public static void main(java.lang.String[] args)
starts a new personal agent. Will be called by an agent place, if agent activation poicy is unshared.
Parameters:
args - commandline arguments