solar.service.directory
Class DistDirectoryService

java.lang.Object
  |
  +--solar.service.BaseService
        |
        +--solar.service.directory.DistDirectoryService
All Implemented Interfaces:
DirectoryConstants, DirectoryService, EventHandler, RequestHandler, RpcConstants, Service

public class DistDirectoryService
extends BaseService
implements DirectoryService, DirectoryConstants, RpcConstants

A distributed implementation of directory service.

Version:
$Id: DistDirectoryService.java,v 1.8 2003/10/05 18:50:56 glchen Exp $
Author:
Guanling Chen

Field Summary
protected  Directory _directory
           
protected  Address _laddr
           
protected  java.util.Hashtable _listeners
           
protected  org.apache.log4j.Logger _log
          The logger for distributed directory service.
protected  RpcService _rpc
           
protected  TransportService _transport
           
 
Fields inherited from class solar.service.BaseService
_inited, _manager, _name
 
Fields inherited from interface solar.service.directory.DirectoryConstants
DIR_ADD_OBSERVER, DIR_ADVERTISE, DIR_ID, DIR_LOOKUP, DIR_NAME, DIR_NAME_ADDED, DIR_NAME_MIGRATED, DIR_NAME_REMOVED, DIR_NAME_UPDATED, DIR_NEWNAME, DIR_NEWREC, DIR_OBSERVER, DIR_OLDNAME, DIR_OLDREC, DIR_PATTERN, DIR_RECORD, DIR_REMOVE_OBSERVER, DIR_UNADVERTISE, DIR_UPDATE
 
Fields inherited from interface solar.service.rpc.RpcConstants
RPC_BLOCK, RPC_HANDLER, RPC_REPLY, RPC_REQUEST, RPC_TIMEOUT
 
Constructor Summary
DistDirectoryService()
           
 
Method Summary
 void addListener(Name pattern, DirectoryListener listener)
          Add a directory listener for the specified pattern.
 java.lang.Object advertise(Name name, Id guid, java.lang.Object obj)
          Advertise a name to the name space, with an app-specific object.
 java.lang.Object handleRequest(Request request)
          Processing a request.
 void initDependents()
          Initialize dependent services here.
 java.util.List lookup(Name pattern)
          Return a list of advertisement whose name matches the pattern.
 void removeListener(Name pattern, DirectoryListener listener)
          Remove a directory listener for the specified pattern.
private  java.util.List requestAll(Name name, Request req)
           
 java.lang.Object unadvertise(Name name, Id guid)
          Unadvertise a name from the name space.
 java.lang.Object update(Name oldname, Id guid, Name newname, java.lang.Object obj)
          Update a name advertisement in the name space.
 
Methods inherited from class solar.service.BaseService
assertInited, getDependentService, getName, getServiceManager, handleDispatchUnit, handleEvent, handleEvent, hasInited, init, init, setInited, setName, setServiceManager, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface solar.service.Service
getName, getServiceManager, handleDispatchUnit, hasInited, init, setName, setServiceManager, start, stop
 
Methods inherited from interface solar.api.EventHandler
handleEvent
 

Field Detail

_log

protected org.apache.log4j.Logger _log
The logger for distributed directory service.


_laddr

protected Address _laddr

_rpc

protected RpcService _rpc

_transport

protected TransportService _transport

_directory

protected Directory _directory

_listeners

protected java.util.Hashtable _listeners
Constructor Detail

DistDirectoryService

public DistDirectoryService()
Method Detail

initDependents

public void initDependents()
                    throws ServiceException
Description copied from interface: Service
Initialize dependent services here.

Specified by:
initDependents in interface Service
Overrides:
initDependents in class BaseService
ServiceException

handleRequest

public java.lang.Object handleRequest(Request request)
                               throws java.lang.Exception
Description copied from interface: RequestHandler
Processing a request.

Specified by:
handleRequest in interface RequestHandler
Overrides:
handleRequest in class BaseService
java.lang.Exception

addListener

public void addListener(Name pattern,
                        DirectoryListener listener)
                 throws DirectoryException
Description copied from interface: DirectoryService
Add a directory listener for the specified pattern.

Specified by:
addListener in interface DirectoryService
DirectoryException

removeListener

public void removeListener(Name pattern,
                           DirectoryListener listener)
                    throws DirectoryException
Description copied from interface: DirectoryService
Remove a directory listener for the specified pattern.

Specified by:
removeListener in interface DirectoryService
DirectoryException

lookup

public java.util.List lookup(Name pattern)
                      throws DirectoryException
Description copied from interface: DirectoryService
Return a list of advertisement whose name matches the pattern.

Specified by:
lookup in interface DirectoryService
DirectoryException

advertise

public java.lang.Object advertise(Name name,
                                  Id guid,
                                  java.lang.Object obj)
                           throws DirectoryException
Description copied from interface: DirectoryService
Advertise a name to the name space, with an app-specific object.

Specified by:
advertise in interface DirectoryService
Returns:
the previous object if there is any.
DirectoryException

unadvertise

public java.lang.Object unadvertise(Name name,
                                    Id guid)
                             throws DirectoryException
Description copied from interface: DirectoryService
Unadvertise a name from the name space.

Specified by:
unadvertise in interface DirectoryService
Returns:
the previous object if there is any.
DirectoryException

update

public java.lang.Object update(Name oldname,
                               Id guid,
                               Name newname,
                               java.lang.Object obj)
                        throws DirectoryException
Description copied from interface: DirectoryService
Update a name advertisement in the name space.

Specified by:
update in interface DirectoryService
Returns:
the previous object if there is any.
DirectoryException

requestAll

private java.util.List requestAll(Name name,
                                  Request req)
                           throws DirectoryException
DirectoryException