-
Notifications
You must be signed in to change notification settings - Fork 38
Component "outjection" for declarative services. #41
Comments
Comment author: Elias N Vasylenko <elias@vasylenko.uk> Sometimes we need to publish (possibly interrelated) services according to patterns which are awkward or impossible to express in the current DS model. For example:
Typically this means leaving the safety and simplicity of DS and manually registering and unregistering services, and manually publishing the relevant capability information in the manifest. I propose to introduce a mechanism for a "master" component to declaratively advertise "subordinate" components which the framework should register on its behalf. I'll describe the design space of the proposal in terms of service annotations rather than the The means by which a master would advertise/expose subordinates would be via @ Component annotations on fields and methods. The SCR would register those fields, and the results of those methods, as components on behalf of the master. When the master component is activated or deactivated, so are its subordinates. So in the following example, in which we have the interfaces
We can also imagine support for adding "field" and "method" targets to other service annotations so they can be applied to subordinate components. Optionally we might also want to support exposing collections of subordinate services. In the following example, we might expect the SCR to behave similarly to as above, but to register each element of the collection returned by
Here we simply have to trust that the referenced object of A limitation of exposing collections of subordinate services is that we can't specify different service properties for each element, which also means that the PID needs to be generated to make them unique. Exposing dynamic subordinates is a little trickier. We might, for example, want to support a pattern where we expose a
In this case, the result of So for the above example, that would mean every time SCR calls There would probably be various constraints on how the components could be configured. For example on service scopes:
Just a suggestion. It's something that I've felt is missing a few times when working with OSGi, and I'd be happy to give a few less abstract examples of use-cases if it'd help. I think probably every single time I've had to manually register services in a |
Original bug ID: BZ#232
From: Elias N Vasylenko <elias@vasylenko.uk>
Reported version: R7
The text was updated successfully, but these errors were encountered: