A blog about my daily tech ramblings.

Friday, 2 August 2013

Injecting OSGi Service Registry in Spring Context

August 02, 2013 Posted by Sachin Handiekar , , , 1 comment

Introduction

In this example we will inject a OSGi service registry inside a Spring Context.

OSGi Service Registry

Let's assume we got a Oracle datasource in our OSGi container with the following service description. (Please see this link)

Spring Configuration

1. Add the OSGi namespace in your Spring context.


2. Using the osgi:reference to get the datasource object.



1 comment:


  1. @Sachin: i have followed the above steps to inject osgi service jndi datasource to the jdbcTemplate, but i am getting the nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate] found for dependency. what could be the issue?

    my spring config is as below

    osgi:reference id="dataSource" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=jdbc/mydb)" />


    ReplyDelete