org.apache.xbean.kernel.standard
Class ServiceManagerRegistry

java.lang.Object
  extended byorg.apache.xbean.kernel.standard.ServiceManagerRegistry

public class ServiceManagerRegistry
extends java.lang.Object

The StandardServiceRegistry manages the registration of ServiceManagers for the kernel.

Since:
2.0
Version:
$Id$
Author:
Dain Sundstrom

Constructor Summary
ServiceManagerRegistry(ServiceManagerFactory serviceManagerFactory)
          Creates a ServiceManagerRegistry that uses the specified service manager factory to create new service managers.
 
Method Summary
 void destroy()
          Stops and destroys all services service managers.
 java.lang.Object getService(java.lang.Class type)
          Gets the first registed and running service that is an instance of the specified type, or null if no instances of the specified type are running.
 ServiceManager getServiceManager(java.lang.Class type)
          Gets the first registered service manager that creates an instance of the specified type, or null if no service managers create an instance of the specified type.
 ServiceManager getServiceManager(ServiceName serviceName)
          Gets the service manager registered under the specified name.
 java.util.List getServiceManagers(java.lang.Class type)
          Gets all service managers that create an instances of the specified type, or an empty list if no service managers create an instance of the specified type.
 java.util.List getServices(java.lang.Class type)
          Gets the all of running service that are an instances of the specified type, or an empty list if no instances of the specified type are running.
 boolean isRegistered(ServiceName serviceName)
          Determines if there is a service registered under the specified name.
 void registerService(ServiceName serviceName, ServiceFactory serviceFactory, java.lang.ClassLoader classLoader)
          Creates a ServiceManager and registers it under the specified name.
 void unregisterService(ServiceName serviceName, StopStrategy stopStrategy)
          Stops and destorys the ServiceManager and then unregisters it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceManagerRegistry

public ServiceManagerRegistry(ServiceManagerFactory serviceManagerFactory)
Creates a ServiceManagerRegistry that uses the specified service manager factory to create new service managers.

Parameters:
serviceManagerFactory - the factory for new service managers
Method Detail

destroy

public void destroy()
             throws KernelErrorsError
Stops and destroys all services service managers. This method will FORCE stop the services if necessary.

Throws:
KernelErrorsError - if any errors occur while stopping or destroying the service managers

isRegistered

public boolean isRegistered(ServiceName serviceName)
Determines if there is a service registered under the specified name.

Parameters:
serviceName - the unique name of the service
Returns:
true if there is a service registered with the specified name; false otherwise

getServiceManager

public ServiceManager getServiceManager(ServiceName serviceName)
                                 throws ServiceNotFoundException
Gets the service manager registered under the specified name.

Parameters:
serviceName - the unique name of the service
Returns:
the ServiceManager
Throws:
ServiceNotFoundException - if there is no service registered under the specified name

getServiceManager

public ServiceManager getServiceManager(java.lang.Class type)
Gets the first registered service manager that creates an instance of the specified type, or null if no service managers create an instance of the specified type.

Parameters:
type - the of the desired service
Returns:
the first registered service manager that creates an instance of the specified type, or null if none found

getServiceManagers

public java.util.List getServiceManagers(java.lang.Class type)
Gets all service managers that create an instances of the specified type, or an empty list if no service managers create an instance of the specified type.

Parameters:
type - the of the desired service managers
Returns:
all service managers that create an instances of the specified type, or an empty list if none found

getService

public java.lang.Object getService(java.lang.Class type)
Gets the first registed and running service that is an instance of the specified type, or null if no instances of the specified type are running.

Parameters:
type - the of the desired service
Returns:
the first registed and running service that is an instance of the specified type or null if none found

getServices

public java.util.List getServices(java.lang.Class type)
Gets the all of running service that are an instances of the specified type, or an empty list if no instances of the specified type are running.

Parameters:
type - the of the desired service
Returns:
the all of running service that are an instances of the specified type, or an empty list if none found

registerService

public void registerService(ServiceName serviceName,
                            ServiceFactory serviceFactory,
                            java.lang.ClassLoader classLoader)
                     throws ServiceAlreadyExistsException,
                            ServiceRegistrationException
Creates a ServiceManager and registers it under the specified name. If the service is restartable, it will enter the server in the STOPPED state. If a service is not restartable, the service manager will assure that all dependencies are satisfied and service will immediately enter in the RUNNING state. If a dependency for a non-restartable service is not immediately satisfiable, this method will throw a ServiceRegistrationException.

Parameters:
serviceName - the unique name of the service
serviceFactory - the factory used to create the service
classLoader - the class loader to use for this service
Throws:
ServiceAlreadyExistsException - if service is already registered with the specified name
ServiceRegistrationException - if the service is not restartable and an error occured while starting the service

unregisterService

public void unregisterService(ServiceName serviceName,
                              StopStrategy stopStrategy)
                       throws ServiceNotFoundException,
                              ServiceRegistrationException
Stops and destorys the ServiceManager and then unregisters it. The ServiceManagerRegistry will attempt to stop the service using the specified stop strategy, but if the service can not be stopped a ServiceRegistrationException will be thrown containing either an UnsatisfiedConditionsException or an IllegalServiceStateException.

Parameters:
serviceName - the unique name of the service
stopStrategy - the strategy that determines how unsatisfied conditions are handled
Throws:
ServiceNotFoundException - if there is no service registered under the specified name
ServiceRegistrationException - if the service could not be stopped


Copyright © {inceptionYear}-2006 Apache Software Foundation. All Rights Reserved.