I have the following setup (on felix osgi framework 4.4.0):
a Bundle B with a DS component C which has a reference R (aQute.bnd.annotation.component.Reference) on a service (provided by some other bundle).
When B is started, a new Component C is instantiated and the reference R is injected properly...
Then I just stop the bundle B, expecting that, if I start it again, that either:
(A) a new Component C' is instantiated and R is injected in C' or
(B) the existing component C is reused and R is injected in C.
What happens is that I have a mixture from (A) and (B) which doesn't work:
a new Component C' is instantiated but R is injected in C, not C'.
My questions are:
Thing is, that my code is too complicated for a simple example, but I need someone to point me to the right direction... in this special case, I have problems interpreting the OSGi specs about declarative services. Is it even defined whether or not a new instance (of Component C) has to be created - or the old one could be reused?
Thanks in advance for any hints!
The correct behavior is (A). Sounds like to you need to file a bug against your DS implementation (not the framework).
When a bundle is stopped, all its components must be deactivated and then discarded never to be reused. So when the bundle is restarting, the DS impl must create new component instances.