All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ajanta.agent.Agent

java.lang.Object
   |
   +----ajanta.agent.Agent

public abstract class Agent
extends Object
implements Serializable
The Agent class is the generic mobile agent. It serves as the base class for all agents. Application-specific agents should be programmed as sub-classes of Agent.

See Also:
Credentials, AgentStatus

Variable Index

 o creatorSignature
signature of the credential signed by creator of the agent
 o cred
Credentials of the agent
 o host
host is the object reference to the current server's environment object.
 o myRef
 o name
URN ( name ) of the agent
 o ownerSignature
signature of the credential signed by owner of the agent
 o status
status object is modified whenever a recall request is pending.

Constructor Index

 o Agent()
Default constructor of the agent which assigns cred, host, ownerSignature and creatorSignature as null
 o Agent(Credentials)
It assigns host, ownerSignature and creatorSignature as null.
 o Agent(Credentials, AgentEnv)
It assigns ownerSignature and creatorSignature as null.

Method Index

 o agentEntry()
It system defined entry protocol and is the first method to be automatically executed every time an agent arrives at a server.
 o agentExit()
Agent's server executes this method just before it is sent off to another server.
 o arrive()
The arrive() method represents an entry protocol.
 o colocate(URN)
This method is called to relocate the agent at the server where a specified "target" object is currently resident.
 o colocate(URN, MethodSpec)
This method is called to relocate the agent at the server where a specified "target" object is currently resident.
 o depart()
The depart() method represents an exit protocol.
 o meet(URN, MethodSpec)
This method acts as the starting point of execution for an agent when it is relocated at a server.
 o recallCommand(URN, URN)
This method is executed by the agent server currenlty hosting this agent when it receives a recall request for this agent.
 o run()
It is a empty method which can be overridden in subclasses.
 o signCreator(URN)
It signs the credentials byte of the agent with specified server's ( creator) private keys and store it in creatorSignature
 o signOwner()
It signs the credentials byte of the agent with owner's private keys and store it in ownerSignature
 o start(AgentEnv, URN, MethodSpec)
After agent has been created this method is called to launch the agent to appropriate server.

Variables

 o name
 public URN name
URN ( name ) of the agent

 o cred
 public Credentials cred
Credentials of the agent

 o ownerSignature
 public byte ownerSignature[]
signature of the credential signed by owner of the agent

 o creatorSignature
 public byte creatorSignature[]
signature of the credential signed by creator of the agent

 o host
 public transient AgentEnv host
host is the object reference to the current server's environment object.

 o status
 public AgentStatus status
status object is modified whenever a recall request is pending. This information is checked in the agentExit method, which is executed when the agent is about to leave a server.

 o myRef
 public Object myRef

Constructors

 o Agent
 public Agent()
Default constructor of the agent which assigns cred, host, ownerSignature and creatorSignature as null

 o Agent
 public Agent(Credentials cred)
It assigns host, ownerSignature and creatorSignature as null. cred is assigned to the Credentials passed as argument.

 o Agent
 public Agent(Credentials cred,
              AgentEnv host)
It assigns ownerSignature and creatorSignature as null. cred is assigned to the Credentials object passed as argument and host to AgentEnv object.

Methods

 o agentEntry
 public final void agentEntry()
It system defined entry protocol and is the first method to be automatically executed every time an agent arrives at a server.

 o arrive
 public abstract void arrive()
The arrive() method represents an entry protocol. It is automatically executed every time an agent arrives at a server. It is an abstract method, and must be overridden in subclasses to define the application-specific entry protocol.

 o depart
 public abstract void depart()
The depart() method represents an exit protocol. It is automatically executed every time an agent leaves a server. It is an abstract method, and must be overridden in subclasses to define the application-specific exit protocol.

 o agentExit
 public final void agentExit()
Agent's server executes this method just before it is sent off to another server. It checks agent's status to find whether a recall is pending or not. If a recall is pending then it colocate the agent to returnTo server set in recall command . If returnTo is not set then it is colocated to guardian of the agent.

 o run
 public void run()
It is a empty method which can be overridden in subclasses. This is the default method which get executed on a server if no other method is specified

 o start
 public void start(AgentEnv host,
                   URN dest,
                   MethodSpec action) throws LaunchFailedException, UnknownHostException
After agent has been created this method is called to launch the agent to appropriate server.

Parameters:
host - AgentEnv instance representing server's environment
dest - URN of the destination server
action - MethodSpec representing the method to be executed on the server if null then run method is executed
 o colocate
 public void colocate(URN target)
This method is called to relocate the agent at the server where a specified "target" object is currently resident.

Parameters:
target - URN of the target object
 o colocate
 public void colocate(URN target,
                      MethodSpec as)
This method is called to relocate the agent at the server where a specified "target" object is currently resident. It execute the meet method on the server. Meet method execute the specified method in the MethodSpec

Parameters:
target - URN of the target object
as - MethodSpec representing the method to be executed by meet method
 o meet
 public void meet(URN reportTo,
                  MethodSpec as)
This method acts as the starting point of execution for an agent when it is relocated at a server. The meet method contains the specification of the actions to be performed by the agent when it is relocated.

 o recallCommand
 public void recallCommand(URN whoInvoked,
                           URN reportTo)
This method is executed by the agent server currenlty hosting this agent when it receives a recall request for this agent. It set the recallPending status of the agent to true.

Parameters:
whoInvoked - URN of the recaller
reportTo - URN of object with whom agent has to colocate on recall
 o signCreator
 public void signCreator(URN serverURN)
It signs the credentials byte of the agent with specified server's ( creator) private keys and store it in creatorSignature

Parameters:
serverURN - URN of the creator of the agent
 o signOwner
 public void signOwner()
It signs the credentials byte of the agent with owner's private keys and store it in ownerSignature


All Packages  Class Hierarchy  This Package  Previous  Next  Index