You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2019/06/28 07:42:00 UTC

[jira] [Resolved] (CAMEL-13682) Wrong bean injection from OSGI

     [ https://issues.apache.org/jira/browse/CAMEL-13682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-13682.
---------------------------------
    Resolution: Not A Bug

This is now @BeanInject work and was designed, to lookup beans of a given type from the registry, its not really taking those osgi specifics into account with that you setup in osgi blueprint with the component-name filtering.

> Wrong bean injection from OSGI
> ------------------------------
>
>                 Key: CAMEL-13682
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13682
>             Project: Camel
>          Issue Type: Bug
>         Environment: Camel 2.16.1, Windows 10 x64, JbossFuse 6.2.1
>            Reporter: Adam Ostrožlík
>            Priority: Minor
>         Attachments: stacktrace.log
>
>
> We issued strange behaviour with our OSGI container setup using services - references and injecting services into out beans using @BeanInject
> *bundle1*
> {code:java}
> <!-- Both beans using same AuditStore interface -->
> <bean id="auditStore" class="store.AuditStoreImpl">
>  <property name="jdbcTemplate" ref="jdbcTemplate"/>
>  <tx:transaction method="*" value="Required"/>
> </bean>
> <bean id="auditStoreOut" class="store.AuditStoreOutImpl">
>  <property name="jdbcTemplate" ref="jdbcTemplate"/>
>  <tx:transaction method="*" value="Required"/>
> </bean>
> <service auto-export="interfaces" ref="auditStore"/>
> <service auto-export="interfaces" ref="auditStoreOut"/>
> {code}
>  
> *bundle2*
> {code:java}
> <reference id="auditStore" component-name="auditStore" interface="eu.unicorn.basse.ms.audit.api.store.AuditStore"/>
> <bean class="SomeBean"/>
> {code}
> *-> injecting reference info bean*
> {code:java}
> class SomeBean {
>    @BeanInject
>    AuditStore auditStore;
> }
> {code}
> From this point, I would expect that OSGI serves only one specific implementation of interface by specifying component-name attribute but it does not.
> As a workaround we managed to inject the reverence using setter or specifing name in @BeanInject annotation - *@BeanInject("auditStore")*
> I do not know if this is normal behaviour. Please, check this.
> Camel version 2.16.1



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)