com.cafesoft.core.service
Interface ServiceManager

All Superinterfaces:
Debuggable, Lifecycle, LifecycleService, Service
All Known Subinterfaces:
ServiceProvider
All Known Implementing Classes:
StandardServiceManager, StandardServiceProvider

public interface ServiceManager
extends LifecycleService

ServiceManager defines an interface for classes that manage a set of Service implementations. This interface extends the Lifecycle interface, which provides a means to start and stop the ServiceManager including any Services managed by it that also implement the Lifecycle interface.


Field Summary
 
Fields inherited from interface com.cafesoft.core.lifecycle.Lifecycle
START_EVENT, STOP_EVENT
 
Method Summary
 void add(Class type, Service service)
          Add a Service to the registry.
 Service[] getServices()
          Returns all of the Services in the registry.
 Service[] lookup(Class type)
          Lookup Services from the registry by type.
 Service lookup(String id)
          Lookup a Service from the registry by unique identifier.
 Service lookup(String id, Class type)
          Lookup a Service from the registry by unique identifier and type.
 void remove(Service service)
          Remove a Service from the registry.
 void setServiceStarter(ServiceStarter serviceStarter)
          Set a ServiceStarter.
 void setServiceStopper(ServiceStopper serviceStopper)
          Set a ServiceStopper.
 
Methods inherited from interface com.cafesoft.core.service.Service
destroy, getServiceConfig, initialize
 
Methods inherited from interface com.cafesoft.core.util.Debuggable
setDebug
 
Methods inherited from interface com.cafesoft.core.lifecycle.Lifecycle
addLifecycleListener, isStarted, removeLifecycleListener, start, stop
 

Method Detail

add

public void add(Class type,
                Service service)
         throws ServiceException
Add a Service to the registry.

Parameters:
type - the Class that identifies the type of service.
service - the Service to be added.
Throws:
ServiceException - if the service is already registered.

remove

public void remove(Service service)
            throws ServiceException
Remove a Service from the registry.

Parameters:
service - the Service to be removed.
Throws:
ServiceException - if the service is not registered.

getServices

public Service[] getServices()
Returns all of the Services in the registry.

Returns:
all of the Services in the registry

lookup

public Service[] lookup(Class type)
                 throws ServiceException
Lookup Services from the registry by type.

Parameters:
type - the Service Class.
Returns:
an array of Service instances implemented by the specified type.
Throws:
ServiceException - if no service with the specified type is registered.

lookup

public Service lookup(String id)
               throws ServiceException
Lookup a Service from the registry by unique identifier.

Parameters:
id - the Service identifier.
Returns:
the Service with the specified identifier.
Throws:
ServiceException - if no service with the specified identifier is registered.

lookup

public Service lookup(String id,
                      Class type)
               throws ServiceException
Lookup a Service from the registry by unique identifier and type.

Parameters:
id - the Service identifier.
type - the Service type.
Returns:
the Service with the specified identifier and type.
Throws:
ServiceException - if no service with the specified identifier and type is registered.

setServiceStarter

public void setServiceStarter(ServiceStarter serviceStarter)
Set a ServiceStarter.

Parameters:
serviceStarter - the ServiceStarter that will handle startup of Service instances when this ServiceManager is started, or null if the default ServiceManager startup behaviour is desired.

setServiceStopper

public void setServiceStopper(ServiceStopper serviceStopper)
Set a ServiceStopper.

Parameters:
serviceStopper - the ServiceStopper that will handle stopping of Service instances when this ServiceManager is stopped, or null if the default ServiceManager stopping behaviour is desired.


Generated on 8:41:50 AM June 06, 2005, © 1996-2005 Cafésoft LLC. All rights reserved.