The OSGi Declarative Services (DS) specifications define annotations which can be processed by tools, like Bnd, into the component description xml which is used at runtime. 112.8.1 in the R6 spec says:
The Component Annotations are not inherited, they can only be used on a given class, annotations on its super class hierarchy or interfaces are not taken into account.
Why are they specified to not allow inheritance?
The DS annotations provided by the Apache Felix project once had support for DS extensibility. Based on this implementation we tried to standardize this as part of the work specificying the official OSGi DS annotations.
The problem, though, is that we get into nasty coupling issues here between two implementation classes across bundle boundaries and we cannot express this dependency properly using Import-Package
or Require-Capability
headers.
Some problems springing to mind:
bind
and unbind
methods private. Would it be ok for DS to call the private bind
or unbind
method on the base class ? (Technically this can well be done, but would it be conceptually ok ?)bind
/unbind
methods are listed in the descriptors provided by and for the extension class and they still name the old method names.bind
/unbind
methods to be protected or public. And thus we force implementation-detail methods to become part of the API. Not very nice IMHO.We argued back then that it would be ok-ish to have such inheritance within a single bundle but came to the conclusion that this limitation, the explanations around it, etc. would not be worth the effort. So we dropped the feature again from the specification roadmap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With