com.lightdev.app.trec.server
Class Agent

java.lang.Object
  extended by com.lightdev.app.trec.server.Agent
All Implemented Interfaces:
SAMApplication
Direct Known Subclasses:
SAMAdministrator, ServerAdministrator

public abstract class Agent
extends Object
implements SAMApplication

Standard class all applications should extend when they are intended to be operated as an agent in the context of the Light Development Transparent Remote Computing (TREC) platform.

A TREC server will automatically guard such applications with the Light Development Simple Access Model (SAM) framework. Applications subclassing this abstract base class need to override methods getRequiredRoleIds, initMethodRoleMappings and initRoleNames with an implementation appropriate to secure remote methods exposed by such subclasses to clients.

All public methods of a TREC agent are exposed to clients as remote methods. They may only use data types conforming to the XML-RPC protocol as parameters and return types. See http://ws.apache.org/xmlrpc/types.html for a list of allowed types and refer to the TREC Manual for more details.

See class ServerAdministrator for an example on how to subclass from this abstract base class.

Version:
2, 31.12.2005
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the BSD License, for details see file license.txt in the distribution package of this software

Field Summary
protected  com.lightdev.lib.xmlrpc.Communicator communicator
           
 
Constructor Summary
Agent()
          create a new instance of an Agent object
 
Method Summary
abstract  void destroy()
          called when the agent goes out of service.
 String getNameForRole(String roleId)
          get the role name for a given role id
abstract  String[] getRequiredRoleIds()
          get ids of all roles required by this agent See class ServerAdministrator for an example of how to do this
 String getRoleForMethod(String methodName)
          get the id of the role required by the method with a given name
abstract  void init()
          called automatically when the agent goes into service.
protected abstract  void initMethodRoleMappings()
          initialize mappings between method names and role ids See class ServerAdministrator for an example of how to do this
protected abstract  void initRoleNames()
          initialize the role names required by this agent See class ServerAdministrator for an example of how to do this
protected  void mapRoleToMethod(String roleIdToMap, String methodNameToMapRoleTo)
          map a role id to a method name Subclasses need to use this method to define the role ids that methods of respective class require.
 void setCommunicator(com.lightdev.lib.xmlrpc.Communicator c)
           
protected  void setNameForRoleId(String roleId, String roleName)
          set the names for the role ids that a subclass of this class defines Subclasses need to use this method to provide a name foreach role id it defines.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

communicator

protected com.lightdev.lib.xmlrpc.Communicator communicator
Constructor Detail

Agent

public Agent()
create a new instance of an Agent object

Method Detail

setCommunicator

public void setCommunicator(com.lightdev.lib.xmlrpc.Communicator c)

mapRoleToMethod

protected void mapRoleToMethod(String roleIdToMap,
                               String methodNameToMapRoleTo)
map a role id to a method name

Subclasses need to use this method to define the role ids that methods of respective class require.

Parameters:
roleIdToMap - the role id to map to a method name
methodNameToMapRoleTo - the mathod name to map the given role id to

setNameForRoleId

protected void setNameForRoleId(String roleId,
                                String roleName)
set the names for the role ids that a subclass of this class defines

Subclasses need to use this method to provide a name foreach role id it defines.

Parameters:
roleId - a role id defined by a subclass of this class
roleName - the name for the given role id

init

public abstract void init()
called automatically when the agent goes into service. Override this method to do all steps a particular agent needs to run


destroy

public abstract void destroy()
called when the agent goes out of service. Override this method to close all resources an agent has open and to destroy all resources an agent has created.


getNameForRole

public String getNameForRole(String roleId)
get the role name for a given role id

Specified by:
getNameForRole in interface SAMApplication
Parameters:
roleId - of role to get the name of
Returns:
the role name

getRequiredRoleIds

public abstract String[] getRequiredRoleIds()
get ids of all roles required by this agent

See class ServerAdministrator for an example of how to do this

Specified by:
getRequiredRoleIds in interface SAMApplication
Returns:
an array of strings having the ids of all roles required by this agent

getRoleForMethod

public String getRoleForMethod(String methodName)
get the id of the role required by the method with a given name

Specified by:
getRoleForMethod in interface SAMApplication
Parameters:
methodName - of method to get the required role of
Returns:
id of role required by the method with the given name

initMethodRoleMappings

protected abstract void initMethodRoleMappings()
initialize mappings between method names and role ids

See class ServerAdministrator for an example of how to do this


initRoleNames

protected abstract void initRoleNames()
initialize the role names required by this agent

See class ServerAdministrator for an example of how to do this