Hi,
I've just pushed the first version of the support for OSGi Service Factories.
It is available on the "service_factories" branch of the project [1].
A sample provider can be found in the tests [2].
Each service factory must provide two methods:
- get_service(bundle, registration):
- this method is called each time a new bundle requests this service.
- Its parameters are the Bundle object describing the caller and the ServiceRegistration corresponding to the requested service
- unget_service(bundle, registration):
- this method is called once a bundle has released all of its services
- the parameters are the same as get_service()
When registering a service factory, it necessary to add the "factory=True" flag to BundleContext.register_service().
It is an early release, so it is buggy: all bug reports are more than welcome.
One of the main issue is that the services created with a factory are not cleaned up automatically after a bundle is stopped.
Also, it doesn't support Prototype Service Factories.