Package com.bc.ceres.core
Interface ServiceRegistry<T>
-
- Type Parameters:
T- The service type. All services are instances of that type.
- All Known Implementing Classes:
DefaultServiceRegistry
public interface ServiceRegistry<T>A registry for services of a specific type.- Since:
- 0.6
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(ServiceRegistryListener<T> listener)Adds a new registry listener.booleanaddService(T service)Adds a new service to this registry.List<ServiceRegistryListener<T>>getListeners()TgetService(String className)Gets a registered service instance for the given class name.Set<T>getServices()Gets all registered services.Class<T>getServiceType()Gets the service type.voidremoveListener(ServiceRegistryListener<T> listener)Removes an existing registry listener.booleanremoveService(T service)Removes an existing service from this registry.
-
-
-
Method Detail
-
getServiceType
Class<T> getServiceType()
Gets the service type. All services in this registry are instances of this type.- Returns:
- The service type.
-
getService
T getService(String className)
Gets a registered service instance for the given class name.- Parameters:
className- The name of the service's class.- Returns:
- The service instance or
nullif no such exists.
-
addService
boolean addService(T service)
Adds a new service to this registry. The method will automatically remove an already registered service of the same type. If the registry changes due to a call of this method, a change event will be fired.- Parameters:
service- The service to be added.- Returns:
trueif the service has been added.
-
removeService
boolean removeService(T service)
Removes an existing service from this registry. If the registry changes due to a call of this method, a change event will be fired.- Parameters:
service- The service to be removed.- Returns:
trueif the service has been removed.
-
getListeners
List<ServiceRegistryListener<T>> getListeners()
- Returns:
- The list of registry listeners.
-
addListener
void addListener(ServiceRegistryListener<T> listener)
Adds a new registry listener.- Parameters:
listener- The registry listener to be added.
-
removeListener
void removeListener(ServiceRegistryListener<T> listener)
Removes an existing registry listener.- Parameters:
listener- The registry listener to be removed.
-
-