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

[ds] allow a component to implement ServiceFactory / PrototypeServiceFactory #688

Open
laeubi opened this issue Mar 1, 2024 · 0 comments

Comments

@laeubi
Copy link
Contributor

laeubi commented Mar 1, 2024

Currently a component must implement the services it exposes through the service factory.

There are sometimes cases where one want to expose a service with DS, but creation of such service won't be possible by DS what for example includes:

  1. The service is not an interface but a final class that needs constructor arguments that are dependencies or need to be constructed from injected services, java records are a good example as well as many (non OSGi) libraries
  2. The constructor is invisible and instances can only be created by a static factory

Current state

This currently forces one to use some indirection, e.g have a component that does not expose a service, injects a bundle context and then register/unregistered the service. This contradicts the idea of letting the SCR manage the service lifecycle, for example this means such a component must always be active and possibly registering services that are never used.

Proposed solution

If a component exposes exactly one service S instead of requiring the component to implement this service it is allowed to alternatively implement the ServiceFactory / PrototypeServiceFactory interface with the generic parameter of <S>.

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

1 participant