com.sdm.quasar.client.core.common.services
Interface ServiceManager

All Superinterfaces:
ServiceProvider
All Known Implementing Classes:
DefaultServiceManager

public interface ServiceManager
extends ServiceProvider

Manages Services. ServiceManager extends ServiceProvider, that capsulates the read-only view to the managed services.

This service manager does not support a hierarchy.

A service is identified by a class object: the interface that defines the service. That interface must extend Service. The implementation must be an object that implements that concrete interface (see {@link #registerService(Class, Service)}).

Note: A service interface that extends another service interface will be considered as a different service.

Note: Implementations of this interface must be threadsafe and be aware that while executing one method the same or any other method may be called again by the same or another thread. Avoid implementations that might deadlock.

Version:
1.0
Author:
Thomas Wolf, Bernd Olleck

Method Summary
 void registerService(java.lang.Class service, Service implementation)
          Registers a service with the manager.
 void replaceService(java.lang.Class service, Service implementation)
          Works like registerService(Class, Service), but overwrites any existing service mapping.
 void unregisterService(java.lang.Class service, Service implementation)
          Unregisters a service.
 
Methods inherited from interface com.sdm.quasar.client.core.common.services.ServiceProvider
getService, hasService
 

Method Detail

registerService

public void registerService(java.lang.Class service,
                            Service implementation)
Registers a service with the manager.

Note that a service should be unregistered before the life cycle of its provider ends.

Parameters:
service - the interface that defines the service
implementation - the object implementing the service
Throws:
java.lang.IllegalArgumentException - if any argument is null or a service mapping already exists for the service key class.

replaceService

public void replaceService(java.lang.Class service,
                           Service implementation)
Works like registerService(Class, Service), but overwrites any existing service mapping.

Parameters:
service - the interface that defines the service
implementation - the object implementing the service
Throws:
java.lang.IllegalArgumentException - if any argument is null

unregisterService

public void unregisterService(java.lang.Class service,
                              Service implementation)
Unregisters a service. If the service is unknown or the given implementation is not the same as the currently known implementation, nothing happens.

Parameters:
service - the interface that defines the service
implementation - the object implementing the service