All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ajanta.server.AgentEnv

java.lang.Object
   |
   +----ajanta.server.AgentEnv

public class AgentEnv
extends Object
class AgentEnv represents the server's context. A reference to an AgentEnv object is passed to each agent when it is executed. Methods in the AgentEnv class provide the agent with primitive operations like migration, resource binding, etc.


Method Index

 o createRMIProxy(String)
Create and install an RMI server which has the same interface as the caller agent.
 o createRMIProxy(String, String)
Create and install an RMI server which has the same interface as the caller agent.
 o createURN(String)
Create a URN by appending the given string onto the server's URN
 o deleteResource(URN)
Delete registered resource entry whose URN is passed as argument.
 o getAgentURN()
Find the name currently executing agent in the same thread group.
 o getCurrentAgent()
Find the currently executing agent in the same thread group.
 o getHostURN()
Return the current host's name
 o getNameReg()
Return a reference to the name registry access class ( NRAccess ) of the current agent server.
 o getResource(URN)
Return an a proxy for the named resource and if it has not yet been registered then return null.
 o go(URN)
Migrate caller to the specified destination and execute the (parameterless) "run" method
 o go(URN, MethodSpec)
Migrate caller to the specified destination and execute the method specified in the MethodSpec
 o go(URN, String, Class[], Object[])
Migrate caller agent to a specified destination and execute the named method with the specified formal and actual parameters
 o go(URN, String, Object[])
Migrate caller to the specified destination and execute the named method with the given actual parameters, assuming they exactly match the formal parameter types.
 o launch(Agent, URN)
Send specified agent to the named destination and execute the (parameterless) "run" method
 o launch(Agent, URN, MethodSpec)
Send specified agent to the named destination and execute the method specified in the MethodSpec
 o launch(Agent, URN, String, Class[], Object[], boolean)
Launch the given agent to the desired destination, specifying the method to be executed there.
 o launch(Agent, URN, String, Object[])
Launch agent to the specified destination and execute the named method with the given actual parameters, assuming they exactly match the formal parameter types.
 o registerAgent(Agent)
Registers an agent with the name registry, If an older entry exists try to rebind.
 o registerResource(URN, Resource)
It creates a resource ( RREntry ) in the agent server's resource registry with the given resource name and resource object
 o registerResourceName(URN)
It creates a resource ( RREntry) in the agent server's resource registry.
 o waitForResource(URN)
Return an a proxy for the named resource and if it has not yet been registered then wait for it.

Methods

 o getCurrentAgent
 public Agent getCurrentAgent()
Find the currently executing agent in the same thread group.

Returns:
Reference to if one exists in current thread group and null otherwise
See Also:
Agent
 o getAgentURN
 public URN getAgentURN()
Find the name currently executing agent in the same thread group.

Returns:
URN of the agent if one exists in current thread group and null otherwise
See Also:
URN
 o getNameReg
 public NRAccess getNameReg()
Return a reference to the name registry access class ( NRAccess ) of the current agent server.

Returns:
NRAccess object of the agent server.
See Also:
NRAccess
 o go
 public void go(URN dest,
                String method,
                Class formals[],
                Object actuals[]) throws UnknownHostException, LaunchFailedException
Migrate caller agent to a specified destination and execute the named method with the specified formal and actual parameters

Parameters:
dest - URN of the destination
method - name of the method to execute
formals - array of class names of method parametrs
actuals - array of objects i.e. values of the parametrs to the method
 o go
 public void go(URN dest,
                String method,
                Object actuals[]) throws UnknownHostException, LaunchFailedException
Migrate caller to the specified destination and execute the named method with the given actual parameters, assuming they exactly match the formal parameter types.

Parameters:
dest - URN of the destination
method - name of the method to execute
actuals - array of objects i.e. values of the parametrs to the method
 o go
 public void go(URN dest) throws UnknownHostException, LaunchFailedException
Migrate caller to the specified destination and execute the (parameterless) "run" method

Parameters:
dest - URN of the destination
 o go
 public void go(URN dest,
                MethodSpec act) throws UnknownHostException, LaunchFailedException
Migrate caller to the specified destination and execute the method specified in the MethodSpec

Parameters:
dest - URN of the destination
act - MethodSpec of the method tb executed at destination
See Also:
MethodSpec
 o launch
 public void launch(Agent ag,
                    URN dest,
                    String method,
                    Class formals[],
                    Object actuals[],
                    boolean first) throws LaunchFailedException
Launch the given agent to the desired destination, specifying the method to be executed there. It is internally called by go methods with first = false.

Parameters:
ag - Reference to the agent being launched
dest - URN of the destination
method - name of the method to execute
formals - array of class names of method parametrs
actuals - array of objects i.e. values of the parametrs to the method
first - true indicate very first launch of the agent ( just after creation ) wheras false indicates a luanch at a later stage in the itinerary
See Also:
Agent
 o launch
 public void launch(Agent ag,
                    URN dest,
                    String method,
                    Object actuals[]) throws UnknownHostException, LaunchFailedException
Launch agent to the specified destination and execute the named method with the given actual parameters, assuming they exactly match the formal parameter types.

Parameters:
ag - Reference to the agent being launched
dest - URN of the destination
method - name of the method to execute
actuals - array of objects i.e. values of the parametrs to the method
See Also:
Agent
 o launch
 public void launch(Agent ag,
                    URN dest) throws UnknownHostException, LaunchFailedException
Send specified agent to the named destination and execute the (parameterless) "run" method

Parameters:
ag - Reference to the agent being launched
dest - URN of the destination
See Also:
Agent
 o launch
 public void launch(Agent ag,
                    URN dest,
                    MethodSpec act) throws UnknownHostException, LaunchFailedException
Send specified agent to the named destination and execute the method specified in the MethodSpec

Parameters:
ag - Reference to the agent being launched
dest - URN of the destination
act - MethodSpec to be executed
See Also:
Agent
 o getHostURN
 public URN getHostURN()
Return the current host's name

Returns:
URN of the current agent server ( host )
 o registerResourceName
 public synchronized void registerResourceName(URN name)
It creates a resource ( RREntry) in the agent server's resource registry. It just associate a null entry with the given URN of the resource. It is usefuel when someone has to wait for a resource which will be initialized by second party at a later stage. It helps in synchronizing them.

Parameters:
name - URN of the resource to be created
 o registerResource
 public synchronized void registerResource(URN name,
                                           Resource obj)
It creates a resource ( RREntry ) in the agent server's resource registry with the given resource name and resource object

Parameters:
name - URN of the resource to be created
obj - Resource object to be registered
See Also:
Resource
 o deleteResource
 public synchronized void deleteResource(URN name)
Delete registered resource entry whose URN is passed as argument.

Parameters:
name - URN of the resource
 o waitForResource
 public synchronized Resource waitForResource(URN resName)
Return an a proxy for the named resource and if it has not yet been registered then wait for it. The proxy to be returned depends on the credentials of the calling agent.Special case - if the resource being requested is this server,return a pointer to the agent server object itself

Parameters:
resName - URN of the resource
Returns:
Resource instance of the proxy for the requested resource.
 o getResource
 public Resource getResource(URN resName)
Return an a proxy for the named resource and if it has not yet been registered then return null. The proxy to be returned depends on the credentials of the calling agent.Special case - if the resource being requested is this server,return a pointer to the agent server object itself

Parameters:
resName - URN of the resource
Returns:
Resource instance of the proxy for the requested resource.
 o createURN
 public URN createURN(String name)
Create a URN by appending the given string onto the server's URN

Parameters:
name - - string used for urn
Returns:
newly creted URN of the form server urn: name
 o createRMIProxy
 public void createRMIProxy(String interf)
Create and install an RMI server which has the same interface as the caller agent. The proxy server has an embedded reference to the agent. It receives the RMI calls and forwards them to the agent. The interface, and the associated proxy class must currently be available on the agent server's classpath. It calls createRMIProxy (String interf,String extension) with extension as "".

Parameters:
interf - name of the "Remote" interface which the agent supports. Extension of the proxy class is "Proxy".
 o createRMIProxy
 public void createRMIProxy(String interf,
                            String extension)
Create and install an RMI server which has the same interface as the caller agent. The proxy server has an embedded reference to the agent. It receives the RMI calls and forwards them to the agent. The interface, and the associated proxy class must currently be available on the agent server's classpath.

Parameters:
interf - name of the "Remote" interface which the agent supports.
extension - file name extension of the proxy class name, if it is "" then by default "Proxy" is used as extension.
 o registerAgent
 public void registerAgent(Agent ag)
Registers an agent with the name registry, If an older entry exists try to rebind.

Parameters:
ag - Agent to be registered

All Packages  Class Hierarchy  This Package  Previous  Next  Index