Class AbstractServiceRegistry<S extends Identifiable<K>,K>
- Type Parameters:
S- type of the identifiable serviceK- type of the key
- All Implemented Interfaces:
Registry<S,K>
AbstractServiceRegistry is an abstract implementation of the Registry interface, that can be used
as a base class for Registry implementations that track registered OSGi services and provide access to them.
This Registry implementation provides access to registered OSGi services by their
Identifiable.getUID(). It does NOT support adding, updating, or removing elements manually.
In comparison to AbstractRegistry, this implementation does not track Providers and query them for
elements. Instead, elements are registered directly as OSGi services. Also, there is no ManagedProvider for
this Registry implementation to write to, so adding, updating, or removing elements through the
Registry methods is not possible. Use this class to implement Registry-like access to OSGi services
of a specific service type. Use AbstractRegistry when elements are to be provided by Providers and
the Registry methods to add, update, and remove elements are required to work.
- Author:
- Florian Hotze - Initial contribution
- Implementation note:
- Implementations must define OSGi bind and unbind methods for the service type they track, and call
addService(Identifiable)andremoveService(Identifiable)when the service is bound or unbound.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the given element to the accordingManagedProvider.voidaddRegistryChangeListener(RegistryChangeListener<@NonNull S> listener) Adds aRegistryChangeListenerto the registry.protected voidaddService(@NonNull S service) @Nullable SThis method retrieves a single element from the registry.getAll()Returns a collection of all elements in the registry.@Nullable SRemoves the given element from the accordingManagedProvider.voidremoveRegistryChangeListener(RegistryChangeListener<@NonNull S> listener) Removes aRegistryChangeListenerfrom the registry.protected voidremoveService(@NonNull S service) stream()Returns a stream of all elements in the registry.@Nullable SUpdates the given element at the accordingManagedProvider.
-
Field Details
-
services
-
listeners
-
-
Constructor Details
-
AbstractServiceRegistry
public AbstractServiceRegistry()
-
-
Method Details
-
addService
-
removeService
-
get
Description copied from interface:RegistryThis method retrieves a single element from the registry. -
getAll
Description copied from interface:RegistryReturns a collection of all elements in the registry. -
stream
Description copied from interface:RegistryReturns a stream of all elements in the registry. -
addRegistryChangeListener
Description copied from interface:RegistryAdds aRegistryChangeListenerto the registry.- Specified by:
addRegistryChangeListenerin interfaceRegistry<S extends Identifiable<K>,K> - Parameters:
listener- registry change listener
-
removeRegistryChangeListener
Description copied from interface:RegistryRemoves aRegistryChangeListenerfrom the registry.- Specified by:
removeRegistryChangeListenerin interfaceRegistry<S extends Identifiable<K>,K> - Parameters:
listener- registry change listener
-
add
Description copied from interface:RegistryAdds the given element to the accordingManagedProvider. -
update
Description copied from interface:RegistryUpdates the given element at the accordingManagedProvider. -
remove
Description copied from interface:RegistryRemoves the given element from the accordingManagedProvider.
-