How to expose and reference services using spring name spaces osgi?

Solution Unverified - Updated -

Environment

  • Red Hat JBoss Fuse
    • 6.2.1

Issue

  • How to expose and reference services using spring name spaces osgi
  • please provide equivalent tag for in spring, so timebeing i can use spring context to load camel route?
  <!--
      Setting up the jpa:// component with the entity manager factory that we set
      up in the 'database' bundle.
    -->
    <reference id="entityManagerFactory" interface="javax.persistence.EntityManagerFactory" />

Resolution

  • An service can be exposed using osgi:service and reference in another bundle using osgi:reference.
  <beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
            xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
            xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">

    <osgi:reference id="entityManagerFactory" interface="javax.persistence.EntityManagerFactory"/>
</beans>

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments