com.sdm.quasar.client.core.dialog.impl
Class DefaultDialogServiceManager

java.lang.Object
  extended bycom.sdm.quasar.client.core.common.services.AbstractServiceManager
      extended bycom.sdm.quasar.client.core.dialog.impl.DefaultDialogServiceManager
All Implemented Interfaces:
DialogServiceManager, DialogServiceProvider, Disposable

public class DefaultDialogServiceManager
extends AbstractServiceManager
implements DialogServiceManager

This service manager manages services of type Service.

Hint: You can use interfaces that don't implement Service by deriving an empty interface that implements Service and use a dynamic proxy redirection to the implementation.

Version:
1.0
Author:
Bernd Olleck, sd&m AG

Field Summary
 
Fields inherited from class com.sdm.quasar.client.core.common.services.AbstractServiceManager
DIRECT, FROM_PARENT, HIERARCHY, virtualRootNode
 
Constructor Summary
DefaultDialogServiceManager(HierarchyManager hierarchyProvider)
          Constructor that initializes this com.sdm.quasar.client.core.dialog.DialogServiceManager without forwarding to an ServiceManager.
DefaultDialogServiceManager(HierarchyManager hierarchyProvider, ID virtualRootNode, ServiceProvider parentServiceProvider)
          Constructor that initializes this com.sdm.quasar.client.core.dialog.DialogServiceManager with a forwarding to an ServiceManager for requests concerning the given virtual root node.
 
Method Summary
 void collectSystemInfo(ID id, SystemInfoNode root, SystemInfoOptions options)
          Builds the system information tree upon local information of the implementor about the dialog with the ID given.
 Service findServiceInHierarchy(ID id, java.lang.Class service)
          Returns the first implementation of a desired service in the hierarchy starting from the node with the given id to the root node.
 Service findServiceInHierarchy(ID id, ID rootID, java.lang.Class service)
          Returns the first implementation of a desired service in the hierarchy starting from the node with the given id to the specified root node.
 Service getServiceDirect(ID id, java.lang.Class service)
          Returns the implementation of a desired service registered at the node with the given id.
 boolean hasServiceDirect(ID id, java.lang.Class service)
          Tests whether a specific node offers a service.
 boolean hasServiceInHierarchy(ID id, java.lang.Class service)
          Tests whether the service is offered in the hierarchy starting from the node with the given id.
 boolean hasServiceInHierarchy(ID id, ID rootID, java.lang.Class service)
          Tests whether the service is offered in the hierarchy starting from the node with the given id to the specified root node.
 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 class com.sdm.quasar.client.core.common.services.AbstractServiceManager
dispose, genericFindServiceInHierarchy, genericGetAllServiceImplementations, genericGetAllServices, genericGetServiceDirect, genericHasServiceDirect, genericHasServiceInHierarchy, genericRegisterService, genericUnregisterService, hasID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDialogServiceManager

public DefaultDialogServiceManager(HierarchyManager hierarchyProvider)
Constructor that initializes this com.sdm.quasar.client.core.dialog.DialogServiceManager without forwarding to an ServiceManager.

Parameters:
hierarchyProvider - the HierarchyManager that governs the hierarchy that is used to organize the Services.

DefaultDialogServiceManager

public DefaultDialogServiceManager(HierarchyManager hierarchyProvider,
                                   ID virtualRootNode,
                                   ServiceProvider parentServiceProvider)
Constructor that initializes this com.sdm.quasar.client.core.dialog.DialogServiceManager with a forwarding to an ServiceManager for requests concerning the given virtual root node. See AbstractServiceManager.virtualRootNode for more information.

Parameters:
hierarchyProvider - the HierarchyManager that governs the hierarchy that is used to organize the Services.
virtualRootNode - the id of the virtual root node
parentServiceProvider - the ServiceManager to which requests concerning the virtual root node are forwarded.
Method Detail

registerService

public void registerService(ID providerId,
                            java.lang.Class service,
                            Service implementation)
Description copied from interface: DialogServiceManager
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 DialogServiceManager.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.

Specified by:
registerService in interface DialogServiceManager
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
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceManager#registerService(com.sdm.quasar.client.core.common.ID, java.lang.Class, com.sdm.quasar.client.core.common.services.Service)

registerServiceForHierarchy

public void registerServiceForHierarchy(ID providerId,
                                        java.lang.Class service,
                                        Service implementation)
Description copied from interface: DialogServiceManager
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 DialogServiceManager.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 DialogServiceManager.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.

Specified by:
registerServiceForHierarchy in interface DialogServiceManager
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
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceManager#registerServiceForHierarchy(com.sdm.quasar.client.core.common.ID, java.lang.Class, com.sdm.quasar.client.core.common.services.Service)

registerServiceFromParent

public void registerServiceFromParent(ID providerId,
                                      java.lang.Class service,
                                      Service implementation)
Description copied from interface: DialogServiceManager
Registers a service for the node with the given id for hierarchical use only; in opposite to DialogServiceManager.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.

Specified by:
registerServiceFromParent in interface DialogServiceManager
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
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceManager#registerServiceFromParent(com.sdm.quasar.client.core.common.ID, java.lang.Class, com.sdm.quasar.client.core.common.services.Service)

unregisterService

public void unregisterService(ID providerId,
                              java.lang.Class service,
                              Service implementation)
Description copied from interface: DialogServiceManager
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.

Specified by:
unregisterService in interface DialogServiceManager
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
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceManager#unregisterService(com.sdm.quasar.client.core.common.ID, java.lang.Class, com.sdm.quasar.client.core.common.services.Service)

hasServiceInHierarchy

public boolean hasServiceInHierarchy(ID id,
                                     java.lang.Class service)
Description copied from interface: DialogServiceProvider
Tests whether the service is offered in the hierarchy starting from the node with the given id.

Specified by:
hasServiceInHierarchy in interface DialogServiceProvider
Parameters:
id - the id of the node at which the search starts towards the root node
service - the class of the service interface that is searched for
Returns:
true iff the service is available.
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceProvider#hasServiceInHierarchy(com.sdm.quasar.client.core.common.ID, java.lang.Class)

hasServiceInHierarchy

public boolean hasServiceInHierarchy(ID id,
                                     ID rootID,
                                     java.lang.Class service)
Description copied from interface: DialogServiceProvider
Tests whether the service is offered in the hierarchy starting from the node with the given id to the specified root node.

Specified by:
hasServiceInHierarchy in interface DialogServiceProvider
Parameters:
id - the id of the node at which the search starts towards the root node
rootID - the root id where to stop looking for a parent provider (may be null or not contained in id's hierarchy tree, which will be threated at the root of the current hierarchy tree)
service - the class of the service interface that is searched for
Returns:
true iff the service is available.
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceProvider#hasServiceInHierarchy(com.sdm.quasar.client.core.common.ID, com.sdm.quasar.client.core.common.ID, java.lang.Class)

findServiceInHierarchy

public Service findServiceInHierarchy(ID id,
                                      java.lang.Class service)
Description copied from interface: DialogServiceProvider
Returns the first implementation of a desired service in the hierarchy starting from the node with the given id to the root node. The returned Object will implement the service interface.

Specified by:
findServiceInHierarchy in interface DialogServiceProvider
Parameters:
id - the id of the node at which the search starts towards the root node
service - the class of the service interface that is searched for
Returns:
the object implementing the service that is registered closest to the node with the given id
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceProvider#findServiceInHierarchy(com.sdm.quasar.client.core.common.ID, java.lang.Class)

findServiceInHierarchy

public Service findServiceInHierarchy(ID id,
                                      ID rootID,
                                      java.lang.Class service)
Description copied from interface: DialogServiceProvider
Returns the first implementation of a desired service in the hierarchy starting from the node with the given id to the specified root node. The returned Object will implement the service interface.

Specified by:
findServiceInHierarchy in interface DialogServiceProvider
Parameters:
id - the id of the node at which the search starts towards the root node
rootID - the root id where to stop looking for a parent provider (may be null or not contained in id's hierarchy tree, which will be threated at the root of the current hierarchy tree)
service - the class of the service interface that is searched for
Returns:
the object implementing the service that is registered closest to the node with the given id
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceProvider#findServiceInHierarchy(com.sdm.quasar.client.core.common.ID, com.sdm.quasar.client.core.common.ID, java.lang.Class)

hasServiceDirect

public boolean hasServiceDirect(ID id,
                                java.lang.Class service)
Description copied from interface: DialogServiceProvider
Tests whether a specific node offers a service. In this case, the hierarchical dependency is ignored.

Specified by:
hasServiceDirect in interface DialogServiceProvider
Parameters:
id - the id of the node
service - the class of the service interface that is searched for
Returns:
true iff the service is available.
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceProvider#hasServiceDirect(com.sdm.quasar.client.core.common.ID, java.lang.Class)

getServiceDirect

public Service getServiceDirect(ID id,
                                java.lang.Class service)
Description copied from interface: DialogServiceProvider
Returns the implementation of a desired service registered at the node with the given id. The returned Object will implement the service interface.

Specified by:
getServiceDirect in interface DialogServiceProvider
Parameters:
id - the id of the node
service - the class of the service interface that is requested
Returns:
the object implementing the service that is registered at the specified node
See Also:
com.sdm.quasar.client.core.dialog.DialogServiceProvider#getServiceDirect(com.sdm.quasar.client.core.common.ID, java.lang.Class)

collectSystemInfo

public void collectSystemInfo(ID id,
                              SystemInfoNode root,
                              SystemInfoOptions options)
Description copied from interface: DialogServiceProvider
Builds the system information tree upon local information of the implementor about the dialog with the ID given.

Specified by:
collectSystemInfo in interface DialogServiceProvider
Parameters:
id - the ID to append system information to the node given
root - the SystemInfoNode to add information to (guaranteed to be not null)
options - contains additional options, that might influence the amount of information added to the tree (guaranteed to be not null)
See Also:
DialogServiceProvider.collectSystemInfo(com.sdm.quasar.client.core.common.ID, com.sdm.quasar.client.core.common.sysinfo.SystemInfoNode, com.sdm.quasar.client.core.common.sysinfo.SystemInfoOptions)