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

    Reuse the beans configuration in camel blueprint

    sarada.ch

      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>

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

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

      </bean>

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

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

        id="hibernate">

      </bean>

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

        id="mysessionFactory" />

      <bean activation="eager"

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

        init-method="afterPropertiesSet">

      </bean>

       

      Is this feature not yet supported in blueprint?

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

          Hello

           

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

           

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

              <service-properties>

                  <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" />

              </service-properties>

          </service>

           

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

           

          <reference id="dataSource"

                     interface="javax.sql.DataSource"

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

           

          regards

          Grzegorz Grzybek