Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ServiceFactory #75

Closed
6 tasks done
tcalmant opened this issue Mar 11, 2017 · 3 comments
Closed
6 tasks done

Add support for ServiceFactory #75

tcalmant opened this issue Mar 11, 2017 · 3 comments
Milestone

Comments

@tcalmant
Copy link
Owner

tcalmant commented Mar 11, 2017

Even if they have been less than 10 answers to the usage survey, the most requested feature is the support for Service Factories.

A Service Factory is a special kind of service that is called by the framework each time it is requested by a bundle: this allows to have one instance (or even implementation) of a service per bundle.
The methods called by the framework are get_service(bundle, service_registration) and unget_service(bundle, service_registration, service_object).
The concept of service factory is defined in the OSGi Core Specification, section 5.9, page 140 (for version 6.0).

The OSGI specification also defines the concept of Prototype Service Factory (section 5.10, page 140) which allows to have multiple service objects, even for the same bundle.
It uses the same un/get_service() methods as the service factory.
This concept also adds a ServiceObjects interface, retrieved with the BundleContext.get_service_objects(service_reference)method (see section 10.1.7.14, page 205).

Both concepts requires the addiction of the concept of service scope (section 5.3, page 134) and to review the way get_service() works, to follow the rules of section 5.4, as Pelix supports only a part of it.

As a result, this feature will come after the following steps:

  • Add support for the service scope property
  • Ensure the BundleContext.get_service() method works as defined by section 5.4.1 (getting a single service)
  • Add the ServiceObjects API
  • Add support for ServiceFactory
  • Add support for PrototypeServiceFactory
  • Update documentation
@tcalmant
Copy link
Owner Author

ServiceFactory feature has been merged in the master branch.
The PrototypeServiceFactory is still to be developped, but might be added in 0.6.6 instead of 0.6.5.

@tcalmant tcalmant modified the milestones: 0.6.5, 0.6.6 Sep 17, 2017
@tcalmant
Copy link
Owner Author

PrototypeServiceFactory have been implemented successfully.
Tests have been added to check their behaviour and to validate that the ServiceObjects API works as described in the OSGi specifications.

A new feature has been added in order to have a sane behaviour: service auto-release.
When a consumer bundle stops, the framework now ensures that all the services it uses are released.
This doesn't mean you can avoid explicit releases, this is mainly a feature to keep a clean state even when a bundle activator fails when the bundle is stopping.

@tcalmant
Copy link
Owner Author

Documentation has been added, so this issue can be closed.
Please open a new issue if a bug is found in the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant