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

java.lang.Object
  extended bycom.sdm.quasar.client.core.dialog.impl.DefaultDialogServiceAccess
All Implemented Interfaces:
DialogServiceAccess

public class DefaultDialogServiceAccess
extends java.lang.Object
implements DialogServiceAccess

Default implementation of DialogServiceAccess that delegates to a DialogServiceManager.

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

Constructor Summary
DefaultDialogServiceAccess(DialogInstanceId diid, ID parentDiid, DialogServiceManager dialogServiceManager)
          Constructor.
 
Method Summary
 Service findServiceInHierarchy(java.lang.Class service)
          Returns the first implementation of a desired service in the hierarchy of the node.
 Service findServiceInParentHierarchy(java.lang.Class service)
          Returns the first implementation of a desired service in the hierarchy of the parent 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(java.lang.Class service)
          Tests if a service exists in the hierarchy of the node.
 boolean hasServiceInParentHierarchy(java.lang.Class service)
          Tests if a service exists in the hierarchy of the parent node.
 void registerService(java.lang.Class service, Service implementation)
          Registers a service for this node.
 void registerServiceForHierarchy(java.lang.Class service, Service implementation)
          Registers a service for this node for hierarchical use only.
 void unregisterService(java.lang.Class service, Service implementation)
          Unregisters a service for this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDialogServiceAccess

public DefaultDialogServiceAccess(DialogInstanceId diid,
                                  ID parentDiid,
                                  DialogServiceManager dialogServiceManager)
Constructor.

Parameters:
diid - the instance id of the dialog
dialogServiceManager - the DialogServiceManager used to satisfy the calls
Method Detail

hasServiceDirect

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

Specified by:
hasServiceDirect in interface DialogServiceAccess
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:
DialogServiceAccess.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: DialogServiceAccess
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 DialogServiceAccess
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:
DialogServiceAccess.getServiceDirect(com.sdm.quasar.client.core.common.ID, java.lang.Class)

hasServiceInHierarchy

public boolean hasServiceInHierarchy(java.lang.Class service)
Description copied from interface: DialogServiceAccess
Tests if a service exists in the hierarchy of the node.

Specified by:
hasServiceInHierarchy in interface DialogServiceAccess
Parameters:
service - the class of the service interface that is searched for
Returns:
true, iff the service is available.
See Also:
DialogServiceAccess.hasServiceInHierarchy(java.lang.Class)

hasServiceInParentHierarchy

public boolean hasServiceInParentHierarchy(java.lang.Class service)
Description copied from interface: DialogServiceAccess
Tests if a service exists in the hierarchy of the parent node.

Specified by:
hasServiceInParentHierarchy in interface DialogServiceAccess
Parameters:
service - the class of the service interface that is searched for
Returns:
true, iff the service is available.
See Also:
DialogServiceAccess.hasServiceInParentHierarchy(java.lang.Class)

findServiceInHierarchy

public Service findServiceInHierarchy(java.lang.Class service)
Description copied from interface: DialogServiceAccess
Returns the first implementation of a desired service in the hierarchy of the node.

Specified by:
findServiceInHierarchy in interface DialogServiceAccess
Parameters:
service - the class of the service interface that is searched for
Returns:
the object implementing the service that is registered closest to the node
See Also:
DialogServiceAccess.findServiceInHierarchy(java.lang.Class)

findServiceInParentHierarchy

public Service findServiceInParentHierarchy(java.lang.Class service)
Description copied from interface: DialogServiceAccess
Returns the first implementation of a desired service in the hierarchy of the parent node.

Specified by:
findServiceInParentHierarchy in interface DialogServiceAccess
Parameters:
service - the class of the service interface that is searched for
Returns:
the object implementing the service that is registered closest to the node
See Also:
DialogServiceAccess.findServiceInParentHierarchy(java.lang.Class)

registerService

public void registerService(java.lang.Class service,
                            Service implementation)
Description copied from interface: DialogServiceAccess
Registers a service for this node. The service class must be an interface that extend Service, and the implementation implement that interface.

If there is already an implementation registered for that service, that implementation is replaced by the passed as a parameter.

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

Specified by:
registerService in interface DialogServiceAccess
Parameters:
service - the interface that defines the service
implementation - the implementation of the service
See Also:
DialogServiceAccess.registerService(java.lang.Class, com.sdm.quasar.client.core.common.services.Service)

registerServiceForHierarchy

public void registerServiceForHierarchy(java.lang.Class service,
                                        Service implementation)
Description copied from interface: DialogServiceAccess
Registers a service for this node for hierarchical use only. The service implementation will not be found by accessing it via DialogServiceAccess.getServiceDirect(ID, Class); it will be found only via DialogServiceAccess.findServiceInHierarchy(Class). Please note, that a service interface can eighter be registered for hierarchical use (this method) or for direct and hierarchical use (see #registerService(ID, Class, Service)). The last registration overwrites the previous; it is not possible to register two different implementations: one for hierarchical and one for direct use!

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

If there is already an implementation registered for that service, that implementation is replaced by the passed as a parameter.

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

Specified by:
registerServiceForHierarchy in interface DialogServiceAccess
Parameters:
service - the interface that defines the service
implementation - the implementation of the service
See Also:
DialogServiceAccess.registerServiceForHierarchy(java.lang.Class, com.sdm.quasar.client.core.common.services.Service)

unregisterService

public void unregisterService(java.lang.Class service,
                              Service implementation)
Description copied from interface: DialogServiceAccess
Unregisters a service for this node.

If the service is not registered for this 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 DialogServiceAccess
Parameters:
service - the interface that defines the service
implementation - the registered implementation of the service
See Also:
DialogServiceAccess.unregisterService(java.lang.Class, com.sdm.quasar.client.core.common.services.Service)