solar.service
Class BaseService

java.lang.Object
  |
  +--solar.service.BaseService
All Implemented Interfaces:
EventHandler, RequestHandler, Service
Direct Known Subclasses:
AbstractDanService, BaseTransportService, CentralDirectoryService, ClientPackService, ClientPubSubService, CompassService, DanClientService, DistDirectoryService, FapClientService, ManualRoutingService, NaiveMulticastService, ScribeMulticastService, ScribePackService, ScribePubSubService, SolarDispatchService, SolarForkService, SolarMobileHostService, SolarRemoteObjectService, SolarRpcService

public class BaseService
extends java.lang.Object
implements Service

A base service implementation.

Version:
$Id: BaseService.java,v 1.23 2003/10/05 18:50:54 glchen Exp $
Author:
Guanling Chen

Field Summary
protected  boolean _inited
           
protected  ServiceManager _manager
           
protected  java.lang.String _name
           
 
Constructor Summary
BaseService()
           
 
Method Summary
protected  void assertInited()
          Check whether the service has been initialized.
protected  Service getDependentService(java.lang.String nameKey, java.lang.String defaultName)
          This method is provided so service can specify a different name key for other services used by it.
 java.lang.String getName()
          Return the name of this service.
 ServiceManager getServiceManager()
          Get the service manager for this service.
 void handleDispatchUnit(DispatchUnit dunit)
          Handle the data unit delivered by dispatch service.
 void handleEvent(Event evt)
          Processing an event.
 void handleEvent(Event evt, Address source)
           
 java.lang.Object handleRequest(Request req)
          Processing a request.
 boolean hasInited()
          Return whether the service has been initialized.
 void init()
          Initiate the service, do not try to init dependent services here.
 void init(java.lang.Object param)
           
 void initDependents()
          Initialize dependent services here.
 void setInited(boolean flag)
           
 void setName(java.lang.String name)
          Set the name of this service.
 void setServiceManager(ServiceManager manager)
          Set the service manager for this service.
 void start()
          Start the service.
 void stop()
          Shutdown the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_manager

protected ServiceManager _manager

_name

protected java.lang.String _name

_inited

protected boolean _inited
Constructor Detail

BaseService

public BaseService()
Method Detail

setInited

public void setInited(boolean flag)

assertInited

protected void assertInited()
Check whether the service has been initialized.


getDependentService

protected Service getDependentService(java.lang.String nameKey,
                                      java.lang.String defaultName)
                               throws ServiceException
This method is provided so service can specify a different name key for other services used by it. For instance: service.transport1.classname = solar.service.transport.UdpTransportService service.transport2.classname = solar.service.transport.TcpTransportService service.myserver.transport = transport1 service.yourserver.transport = transport2

ServiceException

setServiceManager

public void setServiceManager(ServiceManager manager)
Description copied from interface: Service
Set the service manager for this service.

Specified by:
setServiceManager in interface Service

getServiceManager

public ServiceManager getServiceManager()
Description copied from interface: Service
Get the service manager for this service.

Specified by:
getServiceManager in interface Service

setName

public void setName(java.lang.String name)
Description copied from interface: Service
Set the name of this service.

Specified by:
setName in interface Service

getName

public java.lang.String getName()
Description copied from interface: Service
Return the name of this service.

Specified by:
getName in interface Service

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
ServiceException

initDependents

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

Specified by:
initDependents in interface Service
ServiceException

init

public void init(java.lang.Object param)
          throws ServiceException
ServiceException

hasInited

public boolean hasInited()
Description copied from interface: Service
Return whether the service has been initialized.

Specified by:
hasInited in interface Service

start

public void start()
Description copied from interface: Service
Start the service.

Specified by:
start in interface Service

stop

public void stop()
Description copied from interface: Service
Shutdown the service.

Specified by:
stop in interface Service

handleDispatchUnit

public void handleDispatchUnit(DispatchUnit dunit)
                        throws java.lang.Exception
Description copied from interface: Service
Handle the data unit delivered by dispatch service.

Specified by:
handleDispatchUnit in interface Service
java.lang.Exception

handleRequest

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

Specified by:
handleRequest in interface RequestHandler
java.lang.Exception

handleEvent

public void handleEvent(Event evt,
                        Address source)
                 throws java.lang.Exception
java.lang.Exception

handleEvent

public void handleEvent(Event evt)
                 throws java.lang.Exception
Description copied from interface: EventHandler
Processing an event.

Specified by:
handleEvent in interface EventHandler
java.lang.Exception