ajanta.agent
Class JoinableAgent

java.lang.Object
  |
  +--ajanta.agent.Agent
        |
        +--ajanta.agent.ItinAgent
              |
              +--ajanta.agent.JoinableAgent
All Implemented Interfaces:
AccessProtocol, Joinable, Reportable, Resource, java.io.Serializable

public class JoinableAgent
extends ItinAgent
implements Joinable, Resource, AccessProtocol, Reportable

It is a sub class of the ItinAgent class. Typically a splitJoin pattern is executed by an agent of JoinableAgent class. It implements the join method for its child agent to call for joining the parent agent. Moreover agent of this class always registers itself in its server's resource registry on arrival. Its child agent can thus get a reference to it when needed to report back any results. It implements Resource and AccessProtocol so that it can register itself as resource.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class ajanta.agent.ItinAgent
itin
 
Fields inherited from class ajanta.agent.Agent
creatorSignature, cred, host, myRef, name, ownerSignature, status
 
Constructor Summary
JoinableAgent(ajanta.agent.Credentials cred)
           
JoinableAgent(ajanta.agent.Credentials cred, ajanta.pattern.Itinerary itin)
           
 
Method Summary
 void actionBeforeJoin(ajanta.agent.Agent ag)
          This method is executed when a child agent returns and "joins" the parent.
 void actionOnArrive()
          Application specific actions on agent' arrival should be defined in overriden method in the derived class.
 void actionOnJoin()
          This method gets executed by the parent agent when all of the specified child agents have joined and the desired synchronization has occured.
 void arrive()
          The arrive() method represents an entry protocol.
 ajanta.util.Resource getProxy(ajanta.agent.Credentials cred)
          Return a proxy of this agent
 void join(ajanta.agent.Agent ag)
          A child agent reports its result to its parent agent by colocating with the parent agent and calling its join method on it.
 void registerOnArrive()
          This method is called by arrive method.
 void report(ajanta.agent.Agent ag)
          impementation specific report
 
Methods inherited from class ajanta.agent.ItinAgent
checkDepartStatus, depart, getItinerary, noOp, run, setItinerary, start
 
Methods inherited from class ajanta.agent.Agent
agentEntry, agentExit, colocate, colocate, meet, recallCommand, signCreator, signOwner, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoinableAgent

public JoinableAgent(ajanta.agent.Credentials cred)
Parameters:
cred - Credentials object of the agent

JoinableAgent

public JoinableAgent(ajanta.agent.Credentials cred,
                     ajanta.pattern.Itinerary itin)
Parameters:
cred - Credentials object of the agent
itin - Itinerary object for the agent
Method Detail

registerOnArrive

public void registerOnArrive()
This method is called by arrive method. It registers the agent to the server resource registry.


actionOnArrive

public void actionOnArrive()
Application specific actions on agent' arrival should be defined in overriden method in the derived class. For example it can be used to get reference to certain resources of the agent server.


arrive

public final void arrive()
The arrive() method represents an entry protocol. It is automatically executed every time an agent arrives at a server. It is a final method. It calls registerOnArrive and actionOnArrive. Method actionOnArrive can be overriden to take application specific action on agent' arrival.

Overrides:
arrive in class ItinAgent

report

public void report(ajanta.agent.Agent ag)
Description copied from interface: Reportable
impementation specific report

Specified by:
report in interface Reportable
Parameters:
ag - - the agent repoting

join

public void join(ajanta.agent.Agent ag)
A child agent reports its result to its parent agent by colocating with the parent agent and calling its join method on it. It is used to synchronize child agents. It calls actionBeforeJoin where a child agent can pass results to the parent and then it call join() method of the Itinerary.

Specified by:
join in interface Joinable

getProxy

public ajanta.util.Resource getProxy(ajanta.agent.Credentials cred)
Return a proxy of this agent

Specified by:
getProxy in interface AccessProtocol
Parameters:
cred - Credentials object of the caller

actionOnJoin

public void actionOnJoin()
This method gets executed by the parent agent when all of the specified child agents have joined and the desired synchronization has occured. Should be overridden in application specific agents.


actionBeforeJoin

public void actionBeforeJoin(ajanta.agent.Agent ag)
This method is executed when a child agent returns and "joins" the parent. The synchronization protocol executed by the agent results in the execution of this method. This method is used to collect information from a returning agent and it should be suitable overridden by the application specific agents.