You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jörg Jansen <Jo...@inform-software.com> on 2020/10/14 14:11:40 UTC

BeanInject in OSGI-container

Hi everybody, 

not sure if this is the correct channel. 
If not, please let me know.

I'm running camel (3.5.0) in a karaf container (4.2.9).
There I have one bundle which provides a special service (IServiceModelFactory). 

---------------------------------------------------------------------------
Blueprint:
---------------------------------------------------------------------------
<service id="gs-model-factory-intf" ref="gs-model-factory" interface="aero.groundstar.gslisa.base.component.gs.api.factory.IServiceModelFactory" />
<bean id="gs-model-factory" class="aero.groundstar.gslisa.base.component.gs.impl.factory.GsModelFactoryImpl" scope="singleton"/>

---------------------------------------------------------------------------
Visible in container: 
---------------------------------------------------------------------------
karaf@root()> service:list aero.groundstar.gslisa.base.component.gs.api.factory.IServiceModelFactory
[aero.groundstar.gslisa.base.component.gs.api.factory.IServiceModelFactory]
          ---------------------------------------------------------------------------
          osgi.service.blueprint.compname = gs-model-factory
          service.bundleid = 300
          service.id = 1089
          service.scope = bundle
          Provided by :
          GS-LISA :: COMPONENT :: GS-SERVICES :: GS-MODEL-IMPL (300)


The other module is referencing to this service:

---------------------------------------------------------------------------
Blueprint: 
---------------------------------------------------------------------------
<reference id="gs-model-factory" interface="aero.groundstar.gslisa.base.component.gs.api.factory.IServiceModelFactory" />

But when I try to inject this service into another bean, this could not be resolved, because there are two beans available within the CamelContext. 
One is the service itself, the other on a proxy object of this service. 
Is there a way, to disable the proxy or is there another approach to do? 
Kind regards,
Jörg

Re: BeanInject in OSGI-container

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi,

I plan to improve the BeanRepository in camel-osgi.

If your camel-context is in blueprint (<camelContext …/>), then it should take only the ref you defined in the blueprint container.

When you say "inject", you mean something like this:

<bean …><property name="foo" ref="other"/></bean> 

?

Regards
JB

> Le 14 oct. 2020 à 16:11, Jörg Jansen <Jo...@inform-software.com> a écrit :
> 
> Hi everybody, 
> 
> not sure if this is the correct channel. 
> If not, please let me know.
> 
> I'm running camel (3.5.0) in a karaf container (4.2.9).
> There I have one bundle which provides a special service (IServiceModelFactory). 
> 
> ---------------------------------------------------------------------------
> Blueprint:
> ---------------------------------------------------------------------------
> <service id="gs-model-factory-intf" ref="gs-model-factory" interface="aero.groundstar.gslisa.base.component.gs.api.factory.IServiceModelFactory" />
> <bean id="gs-model-factory" class="aero.groundstar.gslisa.base.component.gs.impl.factory.GsModelFactoryImpl" scope="singleton"/>
> 
> ---------------------------------------------------------------------------
> Visible in container: 
> ---------------------------------------------------------------------------
> karaf@root()> service:list aero.groundstar.gslisa.base.component.gs.api.factory.IServiceModelFactory
> [aero.groundstar.gslisa.base.component.gs.api.factory.IServiceModelFactory]
>          ---------------------------------------------------------------------------
>          osgi.service.blueprint.compname = gs-model-factory
>          service.bundleid = 300
>          service.id = 1089
>          service.scope = bundle
>          Provided by :
>          GS-LISA :: COMPONENT :: GS-SERVICES :: GS-MODEL-IMPL (300)
> 
> 
> The other module is referencing to this service:
> 
> ---------------------------------------------------------------------------
> Blueprint: 
> ---------------------------------------------------------------------------
> <reference id="gs-model-factory" interface="aero.groundstar.gslisa.base.component.gs.api.factory.IServiceModelFactory" />
> 
> But when I try to inject this service into another bean, this could not be resolved, because there are two beans available within the CamelContext. 
> One is the service itself, the other on a proxy object of this service. 
> Is there a way, to disable the proxy or is there another approach to do? 
> Kind regards,
> Jörg