net.sf.genuine.organizer.internal
Class DefaultServiceBroker

java.lang.Object
  extended bynet.sf.genuine.organizer.internal.DefaultServiceBroker
All Implemented Interfaces:
InternalServiceBroker, ServiceBroker

public class DefaultServiceBroker
extends java.lang.Object
implements InternalServiceBroker

Default implementation of Genuine's service broker.

Author:
Tim Wellhausen

Constructor Summary
DefaultServiceBroker()
           
 
Method Summary
 void fetchServices(Module module, org.jdom.Element servicesElement)
          The service broker has to fetch all services defined by the given module and keep them internally for later access.
 java.util.List getActiveServices(java.lang.Class serviceType)
          Returns a list of all active services of the given type.
 Service getService(java.lang.Class serviceType)
          Returns the first registered service of the given type.
 java.util.List getServices(java.lang.Class serviceType)
          Returns a list of all services of the given type.
 void registerService(java.lang.Class serviceType, Service service)
          Adds the given service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultServiceBroker

public DefaultServiceBroker()
Method Detail

registerService

public void registerService(java.lang.Class serviceType,
                            Service service)
Adds the given service. Each service is added to a list that contains only services of the same type (= that implement the same interface).

Specified by:
registerService in interface InternalServiceBroker

fetchServices

public void fetchServices(Module module,
                          org.jdom.Element servicesElement)
                   throws ConfigurationException
The service broker has to fetch all services defined by the given module and keep them internally for later access.

Specified by:
fetchServices in interface InternalServiceBroker
Throws:
ConfigurationException

getServices

public java.util.List getServices(java.lang.Class serviceType)
Returns a list of all services of the given type.

Specified by:
getServices in interface ServiceBroker
Parameters:
serviceType - The type of service for which all registered instances should be returned.
Returns:
A list of service instances of the given type. The list might be empty.

getActiveServices

public java.util.List getActiveServices(java.lang.Class serviceType)
Returns a list of all active services of the given type.

Specified by:
getActiveServices in interface ServiceBroker
Parameters:
serviceType - The type of service for which all registered instances that are currently active should be returned.
Returns:
A list of service instances of the given type. The list might be empty.

getService

public Service getService(java.lang.Class serviceType)
Returns the first registered service of the given type.

Specified by:
getService in interface ServiceBroker
Parameters:
serviceType - The type of service for which a registered instance that is currently active should be returned.
Returns:
A Service instance, or null