A factory for bundle scope services.
The factory can provide service objects unique to each bundle.
When registering a service, a
ServiceFactoryobject can be used instead of a service object, so that the bundle developer can gain control of the specific service object granted to a bundle that is using the service.
When this happens, the
BundleContext::GetService(const ServiceReference&)method calls the
ServiceFactory::GetServicemethod to create a service object specifically for the requesting bundle. The service object returned by the
ServiceFactoryis cached by the framework until the bundle releases its use of the service.
When the bundle’s use count for the service equals zero (including the bundle stopping or the service being unregistered), the
ServiceFactory::UngetServicemethod is called.
Subclassed by cppmicroservices::PrototypeServiceFactory
GetService(const Bundle &bundle, const ServiceRegistrationBase ®istration) = 0¶
Creates a new service object.
The Framework invokes this method the first time the specified
bundlerequests a service object using the
BundleContext::GetService(const ServiceReferenceBase&)method. The service factory can then return a specific service object for each bundle.
The framework caches the value returned (unless the InterfaceMap is empty), and will return the same service object on any future call to
BundleContext::GetServicefor the same bundles. This means the framework does not allow this method to be concurrently called for the same bundle.
UngetService(const Bundle &bundle, const ServiceRegistrationBase ®istration, const InterfaceMapConstPtr &service) = 0¶
Releases a service object.
The framework invokes this method when a service has been released by a bundle.