In my current application, I’ve run into this pattern in a couple of places: I have two service interfaces in a single bundle which do different but related jobs.
interface Service1 { ... }
interface Service2 { ... }
and want to have singleton components implementing both, but find each needs a reference to the other:
public class Service1Impl implements Service1 {
private Service2 service2;
...
}
public class Service2Impl implements Service2 {
private Service1 service1;
...
}
Which of the three OSGi component models (DS, Blueprint, and iPOJO) allow this: 1) when Service1Impl and Service2Impl are in the same bundle; 2) when they are in different bundles?
Declarative Services Specification, version 1.1:
Blueprint specification explicitly allows this, provided at least one member of the dependency cycle takes others as properties and not arguments (121.2.6 Cyclic Dependencies):
For iPOJO
(answer received on the mailing list).