public class ProviderRegistryImpl extends java.lang.Object implements ProviderRegistry
Modifier and Type | Class and Description |
---|---|
private class |
ProviderRegistryImpl.BundleProviderLoader
Holder class for located services information.
|
private class |
ProviderRegistryImpl.BundleResources |
private class |
ProviderRegistryImpl.SPIRegistry
Holder class for information about a given collection of
id to provider mappings.
|
Modifier and Type | Field and Description |
---|---|
private Activator |
activator |
static java.lang.String |
EXPORT_PROVIDER_HEADER |
static java.lang.String |
OPT_IN_HEADER |
private ProviderRegistryImpl.SPIRegistry |
providers |
private ProviderRegistryImpl.SPIRegistry |
serviceProviders |
Constructor and Description |
---|
ProviderRegistryImpl(Activator activator) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
addBundle(org.osgi.framework.Bundle bundle)
Add a bundle to the provider registry.
|
java.lang.Object |
getService(java.lang.String providerId)
Locate and instantiate an instance of a service provider
defined in the META-INF/services directory of tracked bundles.
|
java.lang.Class<?> |
getServiceClass(java.lang.String providerId)
Locate and return the class for a service provider
defined in the META-INF/services directory of tracked bundles.
|
java.util.List<java.lang.Class<?>> |
getServiceClasses(java.lang.String providerId)
Locate all services that match a given provider id and return the implementation
classes
|
java.util.List<java.lang.Object> |
getServices(java.lang.String providerId)
Locate all services that match a given provider id and create instances.
|
java.lang.Class<?> |
locate(java.lang.String providerId)
Locate a class by its provider id indicator.
|
java.util.List<java.lang.Class<?>> |
locateAll(java.lang.String providerId)
Locate all class files that match a given provider id.
|
private void |
log(int level,
java.lang.String message) |
private void |
log(int level,
java.lang.String message,
java.lang.Throwable th) |
protected void |
registerProvider(ProviderRegistryImpl.BundleProviderLoader provider)
Register an individual provivider item by its provider identifier.
|
protected void |
registerService(ProviderRegistryImpl.BundleProviderLoader provider)
Register an individual provivider item by its provider identifier.
|
void |
removeBundle(org.osgi.framework.Bundle bundle,
java.lang.Object obj)
Remove a bundle from the registry.
|
protected void |
unregisterProvider(ProviderRegistryImpl.BundleProviderLoader provider)
Removed a provider registration for a named provider id.
|
protected void |
unregisterService(ProviderRegistryImpl.BundleProviderLoader provider)
Removed a provider registration for a named provider id.
|
public static final java.lang.String OPT_IN_HEADER
public static final java.lang.String EXPORT_PROVIDER_HEADER
private ProviderRegistryImpl.SPIRegistry providers
private ProviderRegistryImpl.SPIRegistry serviceProviders
private Activator activator
public ProviderRegistryImpl(Activator activator)
public java.lang.Object addBundle(org.osgi.framework.Bundle bundle)
bundle
- The source bundle.public void removeBundle(org.osgi.framework.Bundle bundle, java.lang.Object obj)
bundle
- The target bundle.protected void registerProvider(ProviderRegistryImpl.BundleProviderLoader provider)
id
- The provider id.provider
- The loader used to resolve the provider class.protected void unregisterProvider(ProviderRegistryImpl.BundleProviderLoader provider)
id
- The target idprovider
- The provider registration instanceprotected void registerService(ProviderRegistryImpl.BundleProviderLoader provider)
id
- The provider id.provider
- The loader used to resolve the provider class.protected void unregisterService(ProviderRegistryImpl.BundleProviderLoader provider)
id
- The target idprovider
- The provider registration instancepublic java.lang.Class<?> locate(java.lang.String providerId)
locate
in interface ProviderRegistry
providerId
- The provider id (generally, a fully qualified class name).public java.util.List<java.lang.Class<?>> locateAll(java.lang.String providerId)
locateAll
in interface ProviderRegistry
providerId
- The target provider identifier.public java.lang.Object getService(java.lang.String providerId) throws java.lang.Exception
getService
in interface ProviderRegistry
providerId
- The name of the target interface class.java.lang.Exception
- Any classloading or other exceptions thrown during
the process of creating this service instance.public java.util.List<java.lang.Object> getServices(java.lang.String providerId)
getServices
in interface ProviderRegistry
providerId
- The target provider identifier.public java.util.List<java.lang.Class<?>> getServiceClasses(java.lang.String providerId)
getServiceClasses
in interface ProviderRegistry
providerId
- The target provider identifier.public java.lang.Class<?> getServiceClass(java.lang.String providerId) throws java.lang.ClassNotFoundException
getServiceClass
in interface ProviderRegistry
providerId
- The name of the target interface class.java.lang.Exception
- Any classloading or other exceptions thrown during
the process of loading this service provider class.java.lang.ClassNotFoundException
private void log(int level, java.lang.String message)
private void log(int level, java.lang.String message, java.lang.Throwable th)