com.sdm.quasar.client.core.dialog
Interface DialogServiceAccess

All Known Subinterfaces:
DialogControl
All Known Implementing Classes:
DefaultDialogControl, DefaultDialogServiceAccess

public interface DialogServiceAccess

The DialogServiceAccess provides methods for acessing and providing services.

The functionality of DialogServiceAccess is an integral part of DialogControl. Every DialogControl is (per inheritence) a DialogServiceAccess!

DialogServiceAccess allows a dialog to:

The look-up of Services along the hierarchy looks for the three(!) possibly registered service instances at this dialog node in the following order:

  1. first look for a service implementation provided for childs,
  2. then look for public provided services,
  3. then look for services provided by the parent (by the SubDialogControl that has the parent dialog to control this dialog node)
  4. and finally look in the parent node the same way (and so on)

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

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.
 

Method Detail

hasServiceDirect

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

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.
Throws:
java.lang.IllegalArgumentException - if the id is unknown or if the service class is not an interface that extends Service.

getServiceDirect

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

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
Throws:
java.lang.IllegalArgumentException - if the id is unknown, if the service class is not an interface that extends Service, or if the service is not available at the given node

hasServiceInHierarchy

public boolean hasServiceInHierarchy(java.lang.Class service)
Tests if a service exists in the hierarchy of the node.

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

hasServiceInParentHierarchy

public boolean hasServiceInParentHierarchy(java.lang.Class service)
Tests if a service exists in the hierarchy of the parent node.

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

findServiceInHierarchy

public Service findServiceInHierarchy(java.lang.Class service)
Returns the first implementation of a desired service in the hierarchy of the node.

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:
com.sdm.quasar.client.core.dialog.DialogServiceProvider#findServiceInHierarchy(com.sdm.quasar.client.core.common.ID, java.lang.Class)

findServiceInParentHierarchy

public Service findServiceInParentHierarchy(java.lang.Class service)
Returns the first implementation of a desired service in the hierarchy of the parent node.

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:
com.sdm.quasar.client.core.dialog.DialogServiceProvider#findServiceInHierarchy(com.sdm.quasar.client.core.common.ID, java.lang.Class)

registerService

public void registerService(java.lang.Class service,
                            Service implementation)
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.

Parameters:
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.

registerServiceForHierarchy

public void registerServiceForHierarchy(java.lang.Class service,
                                        Service implementation)
Registers a service for this node for hierarchical use only. The service implementation will not be found by accessing it via getServiceDirect(ID, Class); it will be found only via 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.

Parameters:
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.

unregisterService

public void unregisterService(java.lang.Class service,
                              Service implementation)
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.

Parameters:
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.