Re: [osgi-dev] Circular reference with Prototype components

2018-11-14 Thread Alain Picard via osgi-dev
Thanks Tim, you're the best. I just figured it out and it was that indeed.
Doesn't solve my issue 100% as it opens a few other more minor issues.

Alain


On Wed, Nov 14, 2018 at 9:47 AM Tim Ward  wrote:

> Hi Alain,
>
> I note that you don’t include the setter code, nor the activation code,
> but at a guess in one of these two places you are calling getService on the
> ComponentServiceObjects. This will in turn cause the ZKRenderer service
> instance to be created. If this instance also has an injected reference to
> the current service (i.e. the one you’re asking about in this email) then
> that’s a cycle. In more complex scenarios there may be other services in
> between, but fundamentally it’s A -> B -> A. The way around this is to
> either:
>
>
>- Remove the cycle entirely
>- Make it so that the dependency in one part can be optionally
>satisfied later
>- Avoid getting an instance from the ComponentServiceObjects until
>*after* your activate is called.
>
>
> I hope this makes sense,
>
> Tim
>
>
> On 14 Nov 2018, at 13:59, Alain Picard via osgi-dev <
> osgi-dev@mail.osgi.org> wrote:
>
> Facing an issue here. I have a component registering service as such:
> @Reference(
> cardinality=ReferenceCardinality.MULTIPLE,
> policy=ReferencePolicy.DYNAMIC,
> scope=PROTOTYPE_REQUIRED,
> target=ZKRenderer.CONFIG_TARGET
> )
> private void addRenderer(ComponentServiceObjects>
> factory, Map props) { ...}
>
> where target is: "(|(iris.zkRenderer.dynamicTester=*)
> (iris.zkRenderer.staticTester.element=*))"
> to capture only instances that have at least one of those properties.
>
> I also have other component that defines services under a subinterface of
> ZKRenderer, but they don't match the filter.
>
> But when they get instantiated via componentServiceObject.getService(); it
> leads to:
> !MESSAGE Circular reference detected trying to get service
> {com.castortech.iris.ecp.view.spi.core.zk.ZKRendererFactory}={service.id=502,
> service.bundleid=418, service.scope=bundle, 
> component.name=com.castortech.iris.ecp.view.internal.zk.ZKRendererFactoryImpl,
> iris.zkRenderer.debug=false, component.id=1066}
>  stack of references:
> ServiceReference: (5 or 6 of those)
>
> debugging I'm finding that it goes through the DependencyManager and seems
> to want to register the service against the above service reference. I
> thought that it was due to the fact that this was a subinterface and added
> the filter, but it doesn't seem to change anything and I'm getting at a
> lost to figure this one out.
>
> 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

Re: [osgi-dev] Circular reference with Prototype components

2018-11-14 Thread Tim Ward via osgi-dev
Hi Alain,

I note that you don’t include the setter code, nor the activation code, but at 
a guess in one of these two places you are calling getService on the 
ComponentServiceObjects. This will in turn cause the ZKRenderer service 
instance to be created. If this instance also has an injected reference to the 
current service (i.e. the one you’re asking about in this email) then that’s a 
cycle. In more complex scenarios there may be other services in between, but 
fundamentally it’s A -> B -> A. The way around this is to either:

Remove the cycle entirely
Make it so that the dependency in one part can be optionally satisfied later
Avoid getting an instance from the ComponentServiceObjects until *after* your 
activate is called.

I hope this makes sense,

Tim


> On 14 Nov 2018, at 13:59, Alain Picard via osgi-dev  
> wrote:
> 
> Facing an issue here. I have a component registering service as such:
> @Reference(
> cardinality=ReferenceCardinality.MULTIPLE, 
> policy=ReferencePolicy.DYNAMIC, 
> scope=PROTOTYPE_REQUIRED, 
> target=ZKRenderer.CONFIG_TARGET
> )
> private void addRenderer(ComponentServiceObjects> factory, 
> Map props) { ...}
> 
> where target is: "(|(iris.zkRenderer.dynamicTester=*) 
> (iris.zkRenderer.staticTester.element=*))"
> to capture only instances that have at least one of those properties.
> 
> I also have other component that defines services under a subinterface of 
> ZKRenderer, but they don't match the filter.
> 
> But when they get instantiated via componentServiceObject.getService(); it 
> leads to: 
> !MESSAGE Circular reference detected trying to get service 
> {com.castortech.iris.ecp.view.spi.core.zk.ZKRendererFactory}={service.id 
> =502, service.bundleid=418, service.scope=bundle, 
> component.name 
> =com.castortech.iris.ecp.view.internal.zk.ZKRendererFactoryImpl,
>  iris.zkRenderer.debug=false, component.id =1066}
>  stack of references: 
> ServiceReference: (5 or 6 of those)
> 
> debugging I'm finding that it goes through the DependencyManager and seems to 
> want to register the service against the above service reference. I thought 
> that it was due to the fact that this was a subinterface and added the 
> filter, but it doesn't seem to change anything and I'm getting at a lost to 
> figure this one out.
> 
> 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

[osgi-dev] Circular reference with Prototype components

2018-11-14 Thread Alain Picard via osgi-dev
Facing an issue here. I have a component registering service as such:
@Reference(
cardinality=ReferenceCardinality.MULTIPLE,
policy=ReferencePolicy.DYNAMIC,
scope=PROTOTYPE_REQUIRED,
target=ZKRenderer.CONFIG_TARGET
)
private void addRenderer(ComponentServiceObjects>
factory, Map props) { ...}

where target is: "(|(iris.zkRenderer.dynamicTester=*)
(iris.zkRenderer.staticTester.element=*))"
to capture only instances that have at least one of those properties.

I also have other component that defines services under a subinterface of
ZKRenderer, but they don't match the filter.

But when they get instantiated via componentServiceObject.getService(); it
leads to:
!MESSAGE Circular reference detected trying to get service
{com.castortech.iris.ecp.view.spi.core.zk.ZKRendererFactory}={service.id=502,
service.bundleid=418, service.scope=bundle,
component.name=com.castortech.iris.ecp.view.internal.zk.ZKRendererFactoryImpl,
iris.zkRenderer.debug=false, component.id=1066}
 stack of references:
ServiceReference: (5 or 6 of those)

debugging I'm finding that it goes through the DependencyManager and seems
to want to register the service against the above service reference. I
thought that it was due to the fact that this was a subinterface and added
the filter, but it doesn't seem to change anything and I'm getting at a
lost to figure this one out.

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