Implementation note. {@link Service} implementations are discoveredusing a Service Provider Interface (SPI), described in {@link ServiceLoader}.
When registering a service, a {@code ServiceFactory} object can be usedinstead of a service object, so that the module developer can gain control of the specific service object granted to a module that is using the service.
When this happens, the {@code ModuleContext.getService(ServiceReference)}method calls the {@code ServiceFactory.getService} method to create a serviceobject specifically for the requesting module. The service object returned by the {@code ServiceFactory} is cached by the Runtime until the modulereleases its use of the service.
When the module's use count for the service is decremented to zero (including the module stopping or the service being unregistered), the {@code ServiceFactory.ungetService} method is called.
{@code ServiceFactory} objects are only used by the Runtime and are notmade available to other modules in the environment. The Runtime may concurrently call a {@code ServiceFactory}. @param < S> Type of Service @author thomas.diesler@jboss.com @since 27-Sep-2013 @see ModuleContext#getService(ServiceReference) @ThreadSafe
When registering a service, a {@code ServiceFactory} object can be usedinstead of a service object, so that the bundle developer can create a customized service object for each bundle that is using the service.
When a bundle {@link BundleContext#getService(ServiceReference) requests} theservice object, the framework calls the {@link #getService(Bundle,ServiceRegistration) getService} method to returna service object customized for the requesting bundle. The returned service object is cached by the Framework for subsequent calls to {@link BundleContext#getService(ServiceReference)} until the bundle releasesits use of the service.
When the bundle's use count for the service is {@link BundleContext#ungetService(ServiceReference) decremented} to zero(including the bundle stopping or the service being unregistered), the framework will call the {@link #ungetService(Bundle,ServiceRegistration,Object) ungetService}method.
{@code ServiceFactory} objects are only used by the Framework and are notmade available to other bundles in the OSGi environment. The Framework may concurrently call a {@code ServiceFactory}. @param < S> Type of Service @see BundleContext#getService(ServiceReference) @ThreadSafe @author $Id: f11fc6bee18315fb659c7987d1b66f1c9c95548a $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|