T
- The type of service which this registry works with.public class ServiceRegistry<T> extends Object
Modifier and Type | Field and Description |
---|---|
static String |
SERVICE_NAME |
Constructor and Description |
---|
ServiceRegistry(org.osgi.framework.BundleContext ctx,
String registrationClassName) |
Modifier and Type | Method and Description |
---|---|
Collection<T> |
getRegisteredServices()
Get all implementations of T which have been registered.
|
T |
getService(Dictionary<String,String> props)
Get a implementation of T matching the properties.
|
T |
getService(String name)
Equivalent to calling getService(props) with a dictionary containing an entry for
SERVICE_NAME with value as name.
|
void |
registerService(T service,
Dictionary<String,?> props)
Register the implementation of T to the OSGi context, with the given properties.
|
void |
registerService(T service,
String name)
Equivalent to calling registerService(service, name, props) with null or empty props.
|
void |
registerService(T service,
String name,
Dictionary<String,String> props)
Equivalent to calling registerService(service, props) with a dictionary containing
an entry for SERVICE_NAME with value as name, in adddition to the contents of props
|
void |
unregisterAll()
Unregister all of the services that have been registered through this registry.
|
public static final String SERVICE_NAME
public ServiceRegistry(org.osgi.framework.BundleContext ctx, String registrationClassName)
public void registerService(T service, Dictionary<String,?> props)
service
- The implementation to be registered.props
- The additional properties which the service should have.public void registerService(T service, String name, Dictionary<String,String> props)
service
- The implementation to be registered.name
- The name to be added as SERVICE_NAME property.props
- Additional properties which the service should be registered with.public void registerService(T service, String name)
service
- The implementation to be registered.name
- The name to be added as SERVICE_NAME property.public void unregisterAll()
public T getService(Dictionary<String,String> props)
props
- The properties which the returned T implementation must match.public T getService(String name)
name
- The name for the service which should be returned.public Collection<T> getRegisteredServices()
Copyright © 2018. All rights reserved.