I have a data access module that provides implementations of repositories using Spring and JDBC.
Therefore, I define a Spring context as follows:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd">
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />
<bean id="annotationTransactionAspect" factory-method="aspectOf" class="org.springframework.transaction.aspectj.AnnotationTransactionAspect">
<property name="transactionManager" ref="transactionManager" />
</bean>
</beans>
I also expose the repositories implementations as services using Declarative Services as follows:
<?xml version="1.0" encoding="UTF-8"?>
<component name="cdr-repository" enabled="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/scr/v1.1.0 http://www.osgi.org/xmlns/scr/v1.1.0">
<!-- Property and Properties -->
<properties entry="OSGI-INF/myrepository-component.properties" />
<!-- Service (optional) -->
<service>
<provide interface="com.example.osgi.dataaccess.api.MyRepository" />
</service>
<!-- Zero or more references to services -->
<!-- Exactly one implementation -->
<implementation class="com.example.osgi.dataaccess.jdbc.impl.MyRepositoryImpl" />
</component>
So, my services are created outside the Spring environment and therefore they are not fully configured (e.g. datasource is not injected).
I'm looking for the right way to integrate Spring with Declarative Services.
Thanks, Mickael