1 Reply Latest reply on Jun 8, 2017 2:11 AM by grgrzybek

    Reuse the beans configuration in camel blueprint


      Hi All,


      I have db connection related beans in camel-blueprint but it is more specific to that bundle. How can I reuse the datasource/sessionconfiguration across other bundle in blueprint.


      For example I have below beans to be reused across all the bundles


      <bean class="org.apache.commons.dbcp.BasicDataSource"

        destroy-method="close" id="dataSource">

        <property name="initialSize" value="20" />

        <property name="maxActive" value="30" />


      <bean class="com.x.dto.ReferenceTable" id="refBean" />

      <bean class="com.x.dao.ReferenceDAOImpl" id="MyBean">


      <!-- setup the Camel hibernate component -->

      <bean class="org.apacheextras.camel.component.hibernate.HibernateComponent"



      <bean activation="eager" factory-method="getObject" factory-ref="mysessionFactoryFactory"

        id="mysessionFactory" />

      <bean activation="eager"

        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" id="mysessionFactoryFactory"




      Is this feature not yet supported in blueprint?

        • 1. Re: Reuse the beans configuration in camel blueprint



          In the blueprint where you define datasource and session factory you just add (for data source):


          <service interface="javax.sql.DataSource" ref="dataSource">


                  <entry key="osgi.jndi.service.name" value="jdbc/mydatasource"/>

                  <entry key="datasource.name" value="mydatasource"/>

                  <entry key="name" value="mydatasource"/>

                  <entry key="aries.xa.aware" value="false" />

                  <entry key="aries.xa.name" value="mydatasource" />




          And in other blueprints (in other bundles) you just add:


          <reference id="dataSource"


                     filter="(datasource.name=mydatasource)" availability="mandatory" />



          Grzegorz Grzybek