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

How do service consumers know whether to use BundleContext::GetService or ServiceObjects? #325

Closed
jeffdiclemente opened this issue Feb 26, 2019 · 3 comments
Assignees

Comments

@jeffdiclemente
Copy link
Member

As a service consumer, its unclear from reading the BundleContext::GetService documentation when to use BundleContext::GetService over ServiceObjects. I'm proposing to make a small doc change to BundleContext::GetService to help users understand when to use one over the other.

@jeffdiclemente jeffdiclemente self-assigned this Feb 26, 2019
@jeffdiclemente
Copy link
Member Author

This also begs the question about why two separate APIs exist to get service objects. I see that ServiceObjects and the concept of service scope was first introduced in OSGi release 6. However I can't find the rationale for why service scope was introduced.
@saschazelzer do you have any insight on why service scopes and the ServiceObjects class were introduced into OSGi release 6 (i.e. what problem was the OSGi Alliance trying to solve)?

@saschazelzer
Copy link
Member

@jeffdiclemente I am not aware of the driving use case for the introduction of service scopes in OSGi. My own use case was stateful services. A service would expose an API to configure certain aspects of its behavior and the service instance is then used repeatedly by the same client. A different client should get a new instance, which has not been configured yet. Also, the service was not thread-safe but clients from different threads should be able to use it, so we used "prototype" scope to isolate service instances.

The different API usage is a little unfortunate, I agree. Better documentation would certainly help new users.

@jeffdiclemente
Copy link
Member Author

@saschazelzer Supporting stateful services seems like a good reason to introduce a prototype service scope. A google search on "stateful services" found a couple blog posts about how to implement stateful services in OSGi before prototype service scopes existed.

jeffdiclemente added a commit that referenced this issue Mar 29, 2019
Make it easier to find information on when the use ServiceObjects.

Fixes #325

[ci skip]

Signed-off-by: The Mathworks Inc <Roy.Lurie@mathworks.com>
jeffdiclemente added a commit that referenced this issue Apr 2, 2019
Make it easier to find information on when to use ServiceObjects.

Fixes #325

Signed-off-by: The Mathworks Inc <Roy.Lurie@mathworks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants