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] support decoration / extender pattern with declarative services #687

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

Comments

@laeubi
Copy link
Contributor

laeubi commented Mar 1, 2024

DS is quite powerful and ease the usage of services, in most cases it even makes the component independent from using OSGi specific API.

There is just one use-case that currently is not well covered, that is the decorator pattern or at OSGi also known as the extender pattern.

Definition

In the context of Services/DS and this request I want to make the following definition:

A service E decorates Service S (or is an extender of S) when for each instance of S in the Service factory there is an instance of E that provides another functionality on behalf of s, that is e.g. wrapping and / or delegating some calls to S and if registering an own service adhere to the principle of property propagation as described in the OSGi Configuration Admin Specification.

Current state

Currently implementing this pattern requires to either use raw OSGi API (e.g. ServiceTrackerCustomizer or ManagedServiceFactory) loosing all benefits of DI/DS or a lot of boilerplate code also it makes the fact less visible (e.g. one component is visible but it registered multiple services that are not declared)

Proposed solution

  1. A DS component is allowed to specify one of its static with 1..1 cardinality services as an "extendee"
  2. A DS component is not allowed to register a service of extendee itself
  3. This will create one new instance of the component for each extendee service getting this particular instance as its service reference
  4. If the component is registers one or more services these must be registered with the component properties unioned by the public ones of the extendee
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