[
https://issues.apache.org/jira/browse/CAMEL-13682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Adam Ostrožlík updated CAMEL-13682:
-----------------------------------
Description:
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
was:
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
> 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
> 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)