The critical part of the spec is available at 
https://osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#service.component-factorycomponent
 
<https://osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#service.component-factorycomponent>
 - the key words are 

"SCR must register a Component Factory service on behalf of the component as 
soon as the component factory is satisfied." 

The Component Factory can’t be satisfied until its reference Y is satisfied, 
which in turn can’t be registered until its mandatory dependency X is 
satisfied. As we can see X won’t be registered until the ComponentFactory 
reference is satisfied. This prevents the whole thing from starting.

You need to break the cycle for this to work. Either you need to change the 
composition of your services, or you need to use Dynamic/Optional for one of 
the references.

I hope this helps,

Tim



> On 23 Nov 2018, at 07:52, Alain Picard via osgi-dev <osgi-dev@mail.osgi.org> 
> wrote:
> 
> Been running into an issue with circular references dealing with 
> ComponentFactory and I'm a bit confused.
> 
> I have:
> @Component
> class A implements X {
>     @Reference(target = CoreDeleteEObjects.CONFIG_TARGET)
>     private ComponentFactory coreDeleteFactory;
> ....
> }
> 
> and the factory component matching my target has a reference to Y which 
> itself has a reference to X. Granted this fails with "standard" references. 
> But here I was under the impression that the referenced service was the 
> ComponentFactory and that the service would get resolved at startup. Testing 
> indicates that I'm wrong.
> 
> What part of the puzzle am I missing? 
> 
> Thanks
> Alain
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to