4. The Generic and Derived AgentServers



    4.1 Extending a Generic AgentServer


Ajanta provides a generic AgentServer that can be suitably extended by a
programmer to define an application-specific server. It supports several
important functions. Each AgentServer conceptually ``contains" two types of
entities --- Agents and resources.  Multiple agents may be hosted by a
server at one time, each running in its own protection domain.  The server
maintains a domain registry, which is a simple database that keeps track of
the agents currently executing on it.  For each agent there exists one DDEntry.

The agent server has an agent environment ( AgentEnv) component -- an
object which acts as the interface, or binding, between visiting agents and the
server.  Incoming agents are given a reference to this object upon arrival.
They can then communicate with the server via the agent environment's interface.
This interface allows agents to request services such as access to resources,
migration to other servers, etc.

 A Resource is an object that acts as an interface to some service or information
available at the host.  For example, a calendar resource (CalendarDB) provides
controlled access to the server owner's appointment calendar.  The server maintains
a resource registry, which is used in setting up safe bindings between resources
and agents.  For each registered resource there exists a RREntry.

It provides a remotely invocable interface (a Java RMI server) .  It supports
status  queries about the agents resident on it, as well as primitives for such
tasks as  terminating agents, recalling them back to their home sites, etc.
Security-sensitive primitives make use of an authentication protocol to ensure
that the caller is authorized to execute them.

4.1 Extending a Generic AgentServer

Programmers can extend AgentServer class in order to add application-specific
functionality, by writing a subclass of AgentServer.  For example, the subclass
could insert application-defined resources into the resource registry.  This is
explained below by means of a CalendarServer example. CalendarServer extends
generic AgentServer class.

public class CalendarServer extends AgentServer

It provides access to calendar database by means of a resource. The name of the
resource is formed as : urn of the server  + "/CalDB". Visiting agents can access this
using getResource method of AgentEnv. CalendarServer creates an instance of
CalendarDB class and register it as resource. Creation and registration is shown
below as part of constructor. Constructor first calls it super passing name of the
server as URN.

 public CalendarServer (String serverURN)
    {
            super(serverURN);  // serverURN is the URN assigned to the server

            CalendarDB cal = new CalendarDB (); // create an instance of CalendarDB
            URN calname = new URN ( myURN + "/CalDB"); // calname is the URN of the resource
            RREntry rre = new RREntry (calname, null, cal); // creates a resource registry entry
            rr.put (calname, rre);  // put it into the resource registry hashtable.
            // rr is hastable where all the resource are registered as name and RREntry pair
}


 GO  TO- Top of this page    Previous Chapter  Next  Chapter    Table of Contents of this Guide