I'm new to OSGI Blueprint and facing a strange issue.
I have 2 separate Databases: oracle and h2(to be used for testing) db
The blueprint container looks something like this:
<service ref='oracleDataSource' interface='javax.sql.DataSource'>
<service-properties>
<entry key='osgi.jndi.service.name' value='someJndiDatasourceName'/>
</service-properties>
</service>
<bean id='oracleDataSource'
class="CustomDataSourceImpl">
<property name="connectionFactoryClassName" value="${datasource.type}"/>
<property name="url" value="${url}"/>
<property name="user" value="${username}"/>
<property name="password" value="${password}"/>
<property name="validateConnectionOnBorrow" value="true"/>
</bean>
Clearly, the service above binds to oracleDataSource . The datasource.type property gets populated from a configuration file and has a value of oracle.jdbc.pool.OracleDataSource
Now, my use-case is that suppose if I want to edit the configuration file later and change the value of datasource.type to h2 type, then my service-ref should bind to the bean mentioned below:
<bean id="h2ds" class="org.h2.jdbcx.JdbcDataSource">
<property name="URL" value="${url}"/>
<property name="user" value="${username}"/>
<property name="password" value="${password}"/>
</bean>
Can we do such kind of dynamic binding in blueprint?
Basically, I'm looking for something similar to service locator.