com.sdm.quasar.client.core.dialog.impl
Interface DialogServiceManager

All Superinterfaces:
DialogServiceProvider
All Known Implementing Classes:
DefaultDialogServiceManager

public interface DialogServiceManager
extends DialogServiceProvider

Allows registration of services that are hierarchically organized along a dialog hierarchy.

Implementations of this interface should be threadsafe.

Note: if we'd use java 1.5, this would be a generic.

Version:
1.0
Author:
Martin Haft, sd&m AG, Thomas Wolf, sd&m AG, Bernd Olleck, sd&m AG
See Also:
DialogServiceProvider

Method Summary
 void registerService(ID providerId, java.lang.Class service, Service implementation)
          Registers a public service implementation for the node with the given id.
 void registerServiceForHierarchy(ID providerId, java.lang.Class service, Service implementation)
          Registers a service implmentation for the node with the given id for hierarchical use only.
 void registerServiceFromParent(ID providerId, java.lang.Class service, Service implementation)
          Registers a service for the node with the given id for hierarchical use only; in opposite to registerServiceForHierarchy(ID, Class, Service), the service will be found after the hierarchical service and the direct service was found.
 void unregisterService(ID providerId, java.lang.Class service, Service implementation)
          Unregisters a service for a given node.
 
Methods inherited from interface com.sdm.quasar.client.core.dialog.impl.DialogServiceProvider
collectSystemInfo, findServiceInHierarchy, findServiceInHierarchy, getServiceDirect, hasServiceDirect, hasServiceInHierarchy, hasServiceInHierarchy
 

Method Detail

registerService

public void registerService(ID providerId,
                            java.lang.Class service,
                            Service implementation)
Registers a public service implementation for the node with the given id. The service class must be an interface that extend Service, and the implementation implement that interface.

Public services will be accessible by DialogServiceProvider.getServiceDirect(ID, Class) and will be found by DialogServiceProvider.findServiceInHierarchy(ID, Class) after a potentially registered hierarchy-only service was found (see registerServiceForHierarchy(ID, Class, Service)} for this case.

If there is already a public implementation registered for that service, an IllegalArgumentException will be thrown.

Please note that a a registered service should be unregistered when the life cycle of the provider ends.

Parameters:
providerId - the id of the node where the service should be registered
service - the interface that defines the service
implementation - the implementation of the service
Throws:
java.lang.IllegalArgumentException - if the providerId is unknown, service is not an interface or does not extend Service, or the implementation does not implement the interface that defines the service or there is already a public service implementation registered

registerServiceForHierarchy

public void registerServiceForHierarchy(ID providerId,
                                        java.lang.Class service,
                                        Service implementation)
Registers a service implmentation for the node with the given id for hierarchical use only.

The service implementation will not be found by accessing it via DialogServiceProvider.getServiceDirect(ID, Class); it will be found only via DialogServiceProvider.findServiceInHierarchy(ID, Class).

Please note, that different service implementations of a service interface can be registered for hierarchical use (this method) and for direct use (see registerService(ID, Class, Service)). By using DialogServiceProvider.findServiceInHierarchy(ID, Class) the service implementation registered using this method will be found before the service registered using registerService(ID, Class, Service).

The service class must be an interface that extend Service, and the implementation implement that interface.

If there is already a hierarchical implementation registered for that service, an IllegalArgumentException will be thrown.

Please note that a a registered service should be unregistered when the life cycle of the provider ends.

Parameters:
providerId - the id of the node where the service should be registered
service - the interface that defines the service
implementation - the implementation of the service
Throws:
java.lang.IllegalArgumentException - if the providerId is unknown, service is not an interface or does not extend Service, or the implementation does not implement the interface that defines the service or there is already a hierarchical service implementation registered

registerServiceFromParent

public void registerServiceFromParent(ID providerId,
                                      java.lang.Class service,
                                      Service implementation)
Registers a service for the node with the given id for hierarchical use only; in opposite to registerServiceForHierarchy(ID, Class, Service), the service will be found after the hierarchical service and the direct service was found.

The service class must be an interface that extend Service, and the implementation implement that interface.

If there is already a parent implementation registered for that service, an IllegalArgumentException will be thrown.

Please note that a a registered service should be unregistered when the life cycle of the provider ends.

Parameters:
providerId - the id of the node where the service should be registered
service - the interface that defines the service
implementation - the implementation of the service
Throws:
java.lang.IllegalArgumentException - if the providerId is unknown, service is not an interface or does not extend Service, or the implementation does not implement the interface that defines the service or there is already a parent service implementation registered

unregisterService

public void unregisterService(ID providerId,
                              java.lang.Class service,
                              Service implementation)
Unregisters a service for a given node.

If the service is not registered for the given node or the given implementation is not the one that is registered, nothing happens.

Therefore, if a service implementation is replaced by another implementation, the unregistering of the first implementation is harmless since the second implementation will stay registered. However, if the second implementation is unregistered first, then no service will be available, even though the first service implementation hasn't been unregistered yet.

Parameters:
providerId - the id of the node where the service should be unregistered
service - the interface that defines the service
implementation - the registered implementation of the service
Throws:
java.lang.IllegalArgumentException - if the providerId is unknown, service is not an interface or does not extend Service, or the implementation does not implement the interface that defines the service.