solar.service.directory
Class CentralDirectoryService

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

public class CentralDirectoryService
extends BaseService
implements DirectoryService, RpcConstants

A centralized directory service, which requires a rpc and a transport services.

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

Field Summary
protected  Directory _directory
           
protected  DispatchService _dispatch
           
protected  Address _laddr
           
protected  java.util.Hashtable _listeners
           
protected  boolean _local
           
protected  org.apache.log4j.Logger _log
          The logging facility.
protected  RpcService _rpc
           
protected  Address _server
           
protected  java.lang.String _transport
           
 
Fields inherited from class solar.service.BaseService
_inited, _manager, _name
 
Fields inherited from interface solar.service.rpc.RpcConstants
RPC_BLOCK, RPC_HANDLER, RPC_REPLY, RPC_REQUEST, RPC_TIMEOUT
 
Constructor Summary
CentralDirectoryService()
           
 
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.
private  java.lang.Object callRpc(Request req)
           
private  void doAddListener(Name pattern, DirectoryListener listener)
           
private  java.lang.Object doAdvertise(Name name, NameRecord rec)
           
private  java.util.List doLookup(Name pattern)
           
private  void doRemoveListener(Name pattern, DirectoryListener listener)
           
private  java.lang.Object doUnadvertise(Name name, NameRecord rec)
           
private  java.lang.Object doUpdate(Name oldname, NameRecord oldrec, Name newname, NameRecord newrec)
           
 java.lang.Object handleRequest(Request request)
          Processing a request.
 void init()
          Initiate the service, do not try to init dependent services here.
 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.
 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, 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, setName, setServiceManager, start, stop
 
Methods inherited from interface solar.api.EventHandler
handleEvent
 

Field Detail

_log

protected org.apache.log4j.Logger _log
The logging facility.


_local

protected boolean _local

_server

protected Address _server

_dispatch

protected DispatchService _dispatch

_rpc

protected RpcService _rpc

_transport

protected java.lang.String _transport

_laddr

protected Address _laddr

_directory

protected Directory _directory

_listeners

protected java.util.Hashtable _listeners
Constructor Detail

CentralDirectoryService

public CentralDirectoryService()
Method Detail

init

public void init()
          throws ServiceException
Description copied from interface: Service
Initiate the service, do not try to init dependent services here.

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

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

callRpc

private java.lang.Object callRpc(Request req)
                          throws RpcException
RpcException

doAddListener

private void doAddListener(Name pattern,
                           DirectoryListener listener)
                    throws DirectoryException
DirectoryException

doRemoveListener

private void doRemoveListener(Name pattern,
                              DirectoryListener listener)
                       throws DirectoryException
DirectoryException

doLookup

private java.util.List doLookup(Name pattern)
                         throws DirectoryException
DirectoryException

doAdvertise

private java.lang.Object doAdvertise(Name name,
                                     NameRecord rec)
                              throws DirectoryException
DirectoryException

doUnadvertise

private java.lang.Object doUnadvertise(Name name,
                                       NameRecord rec)
                                throws DirectoryException
DirectoryException

doUpdate

private java.lang.Object doUpdate(Name oldname,
                                  NameRecord oldrec,
                                  Name newname,
                                  NameRecord newrec)
                           throws DirectoryException
DirectoryException