com.sdm.quasar.client.core.common.services
Class DefaultServiceManager

java.lang.Object
  extended bycom.sdm.quasar.client.core.common.services.DefaultServiceManager
All Implemented Interfaces:
ServiceManager, ServiceProvider, SystemInfoProvider

public class DefaultServiceManager
extends java.lang.Object
implements ServiceManager, SystemInfoProvider

Default implementation of the ServiceManager. Uses a com.sdm.quasar.client.core.common.services.impl.ServiceNode to manage the services.


Constructor Summary
DefaultServiceManager()
          Constructor.
 
Method Summary
 void collectSystemInfo(SystemInfoNode root, SystemInfoOptions options)
          Builds the system information tree upon local information of the implementor.
 Service getService(java.lang.Class service)
          Returns the service implementation registered with the service manager.
 boolean hasService(java.lang.Class service)
          Tests, whether a service is registered with the service manager.
 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultServiceManager

public DefaultServiceManager()
Constructor.

Method Detail

registerService

public void registerService(java.lang.Class service,
                            Service implementation)
Description copied from interface: ServiceManager
Registers a service with the manager.

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

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

replaceService

public void replaceService(java.lang.Class service,
                           Service implementation)
Description copied from interface: ServiceManager
Works like ServiceManager.registerService(Class, Service), but overwrites any existing service mapping.

Specified by:
replaceService in interface ServiceManager
Parameters:
service - the interface that defines the service
implementation - the object implementing the service
See Also:
ServiceManager.replaceService(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: ServiceManager
Unregisters a service. If the service is unknown or the given implementation is not the same as the currently known implementation, nothing happens.

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

hasService

public boolean hasService(java.lang.Class service)
Description copied from interface: ServiceProvider
Tests, whether a service is registered with the service manager.

Specified by:
hasService in interface ServiceProvider
Parameters:
service - the interface that defines the service
Returns:
true, iff an implementation is registered for the given service.
See Also:
ServiceProvider.hasService(java.lang.Class)

getService

public Service getService(java.lang.Class service)
Description copied from interface: ServiceProvider
Returns the service implementation registered with the service manager.

Specified by:
getService in interface ServiceProvider
Parameters:
service - the interface that defines the service
Returns:
the implementation for the service interface.
See Also:
ServiceProvider.getService(java.lang.Class)

collectSystemInfo

public void collectSystemInfo(SystemInfoNode root,
                              SystemInfoOptions options)
Description copied from interface: SystemInfoProvider
Builds the system information tree upon local information of the implementor. The system information tree can be used within development by inspecting the system; so implementors should append their internal state (depending on the details settings within SystemInfoOptions). The information can be appended to the tree by adding new child SystemInformationNodes to the root node given using the SystemInfoNode.createChild(String) method and by setting information attributes the these nodes or the given root node.

Specified by:
collectSystemInfo in interface SystemInfoProvider
Parameters:
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:
SystemInfoProvider.collectSystemInfo(com.sdm.quasar.client.core.common.sysinfo.SystemInfoNode, com.sdm.quasar.client.core.common.sysinfo.SystemInfoOptions)