toolbox.services
Interface ServiceRegistry

Package class diagram package ServiceRegistry
All Known Implementing Classes:
ServiceRegistryImpl

public interface ServiceRegistry

Interface that defines a service registry.

The registry is the heart of the services package. Registry implementations must manage the service lifecycle and manage the relationship between services and their corresponding environments.


Method Summary
 void destroy()
          Destroy this registry.
 java.lang.String getProperty(java.lang.String name)
          Return the value of the named registry configuration property.
 java.lang.Object getService(java.lang.String name, java.lang.Class clazz)
          Create and return an instance of the named service.
 void init(java.lang.String name, java.lang.String config)
          Initialise this registry.
 void loadEnvironment(java.lang.String name)
          Force the registry to load the named environment.
 

Method Detail

init

void init(java.lang.String name,
          java.lang.String config)
          throws ServiceException
Initialise this registry.

Parameters:
name - String containing the registry name.
config - File path to the configuration of this registry. The configuration should define all the services supported by this registry.
Throws:
ServiceException - if the registry cannot be created.

getService

java.lang.Object getService(java.lang.String name,
                            java.lang.Class clazz)
                            throws ServiceException
Create and return an instance of the named service.

This method must handle the instantiation of the service and inject the required service environment and configuration properties into the service. The injection is done using the create(..) method defined in the Service interface.

Parameters:
name - String containing the name or identifier for the services.
clazz - The class that is the implementation of the service.
Returns:
Object containing an instance of the service.
Throws:
ServiceException - if the service cannot be created and returned.

loadEnvironment

void loadEnvironment(java.lang.String name)
                     throws ServiceException
Force the registry to load the named environment. This can be useful when the environment utilises a callback mechanism when communicating with service related classes.

Parameters:
name - String containing the name of the environment to load.
Throws:
ServiceException - if the environment cannot be loaded.

getProperty

java.lang.String getProperty(java.lang.String name)
Return the value of the named registry configuration property.

Parameters:
name - String containing property name.
Returns:
String containing the value of the property.

destroy

void destroy()
             throws ServiceException
Destroy this registry.

Throws:
ServiceException