osgi / bugzilla-archive

Archive of OSGi Alliance Specification Bugzilla bugs. The Specification Bugzilla system was decommissioned with the move to GitHub. The issues in this repository are imported from the Specification Bugzilla system for archival purposes.
0 stars 1 forks source link

[DS] Call dynamic reference bind/unbind methods after activation #2852

Closed bjhargrave closed 7 years ago

bjhargrave commented 7 years ago

Original bug ID: BZ#2984 From: @rinswind Reported version: R7

bjhargrave commented 7 years ago

Comment author: @rinswind

An example typical for a whiteboard component:

The most natural way to code such a whiteboard fails. When bind/unbind are called sometimes the static services are not present and always the state prepared by activate() is not setup. As a result a more complex pattern needs to be implemented.

This pattern is so common that it is worth for the specification to support it directly. I.e. in section 112.5.6 of the enterprise spec change the activation order to:

  1. Load the component implementation class.
  2. Create the component instance and component context.
  3. Bind the target services which use static policy.
  4. Call the activate method, if present.
  5. Bind the target services which use dynamic policy.
bjhargrave commented 7 years ago

Comment author: @cziegeler

I'm not sure if it's a good idea to change the behaviour. In addition, bnd puts the references into the XML in order of their name, so you can play around with names and therefore force that a static reference is set before a dynamic one. With R7 we have constructor injection and activation fields which both solve this problem as well.

bjhargrave commented 7 years ago

Comment author: @rinswind

I have to agree that constructor injection will solve this.

Constructor injection already complicates the activation order so adding more complexity needs a stronger use case.

Closing the issue.