Using a bean instead of driverProperties

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using a bean instead of driverProperties

Jaco de Groot
Hi,

Last weeks I've integrated BTM in our project. I'd like to thank you for
this nice product! :)

I made some little changes to make it possible to set a bean on the
PoolingDataSource and PoolingConnectionFactory in my Spring
configuration instead of using driverProperties, see attached changed
java files, based on btm-dist-2.1.3.zip. For creating an
ActiveMQXAConnectionFactory bean in Spring and adding it to the
PoolingConnectionFactory you can now use the following Spring configuration:

<bean
   name="activeMQConnectionFactory"
   class="org.apache.activemq.ActiveMQXAConnectionFactory"
   scope="singleton"
   destroy-method="stop"
   >
   <property name="brokerURL" value="vm://localhost"/>
</bean>

<bean
   name="defaultConnectionFactory"
   class="bitronix.tm.resource.jms.PoolingConnectionFactory"
   init-method="init"
   destroy-method="close"
   >
   <property name="uniqueName"
value="${instance.name.lc}.defaultConnectionFactory"/>
   <property name="maxPoolSize" value="100" />
   <property name="allowLocalTransactions" value="true"/>
   <property name="resource">
     <ref bean="activeMQConnectionFactory"/>
   </property>
</bean>

And/or using Spring to get a DataSource from JNDI and adding it to the
PoolingDataSource bean:

<bean
   name="jndiDataSource"
   class="org.springframework.jndi.JndiObjectFactoryBean"
   >
   <property name="jndiName"
value="${jndiContextPrefix}jdbc/${instance.name.lc}"/>
</bean>

<bean
   name="defaultDataSource"
   class="bitronix.tm.resource.jdbc.PoolingDataSource"
   init-method="init"
   destroy-method="close"
   >
   <property name="uniqueName"
value="${instance.name.lc}.defaultDataSource"/>
   <property name="maxPoolSize" value="20"/>
   <property name="resource">
     <ref bean="jndiDataSource"/>
   </property>
</bean>

While searching for the mailinglist details on the website I just came
across the following Improvement request:

http://jira.codehaus.org/browse/BTM-83

Might be resolved with my changes. :)

Regards, Jaco


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

JdbcPooledConnection.java (19K) Download Attachment
JmsPooledConnection.java (11K) Download Attachment
ResourceBean.java (12K) Download Attachment
XAPool.java (24K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using a bean instead of driverProperties

Ludovic Orban-2
Hi Jaco,

Sorry for the delay coming back to you.


Thanks for the patches, but I'd be very glad if you could attach them to the BTM-83 jira. This way they won't get lost and will eventually be processed.


Thanks,
Ludovic


On Sat, Sep 8, 2012 at 12:38 PM, Jaco de Groot <[hidden email]> wrote:
Hi,

Last weeks I've integrated BTM in our project. I'd like to thank you for this nice product! :)

I made some little changes to make it possible to set a bean on the PoolingDataSource and PoolingConnectionFactory in my Spring configuration instead of using driverProperties, see attached changed java files, based on btm-dist-2.1.3.zip. For creating an ActiveMQXAConnectionFactory bean in Spring and adding it to the PoolingConnectionFactory you can now use the following Spring configuration:

<bean
  name="activeMQConnectionFactory"
  class="org.apache.activemq.ActiveMQXAConnectionFactory"
  scope="singleton"
  destroy-method="stop"
  >
  <property name="brokerURL" value="vm://localhost"/>
</bean>

<bean
  name="defaultConnectionFactory"
  class="bitronix.tm.resource.jms.PoolingConnectionFactory"
  init-method="init"
  destroy-method="close"
  >
  <property name="uniqueName" value="${instance.name.lc}.defaultConnectionFactory"/>
  <property name="maxPoolSize" value="100" />
  <property name="allowLocalTransactions" value="true"/>
  <property name="resource">
    <ref bean="activeMQConnectionFactory"/>
  </property>
</bean>

And/or using Spring to get a DataSource from JNDI and adding it to the PoolingDataSource bean:

<bean
  name="jndiDataSource"
  class="org.springframework.jndi.JndiObjectFactoryBean"
  >
  <property name="jndiName" value="${jndiContextPrefix}jdbc/${instance.name.lc}"/>
</bean>

<bean
  name="defaultDataSource"
  class="bitronix.tm.resource.jdbc.PoolingDataSource"
  init-method="init"
  destroy-method="close"
  >
  <property name="uniqueName" value="${instance.name.lc}.defaultDataSource"/>
  <property name="maxPoolSize" value="20"/>
  <property name="resource">
    <ref bean="jndiDataSource"/>
  </property>
</bean>

While searching for the mailinglist details on the website I just came across the following Improvement request:

http://jira.codehaus.org/browse/BTM-83

Might be resolved with my changes. :)

Regards, Jaco


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Using a bean instead of driverProperties

Jaco de Groot
Done.

Regards, Jaco

Op 11-11-12 22:21, Ludovic Orban schreef:

> Hi Jaco,
>
> Sorry for the delay coming back to you.
>
>
> Thanks for the patches, but I'd be very glad if you could attach them to
> the BTM-83 jira. This way they won't get lost and will eventually be
> processed.
>
>
> Thanks,
> Ludovic
>
>
> On Sat, Sep 8, 2012 at 12:38 PM, Jaco de Groot <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi,
>
>     Last weeks I've integrated BTM in our project. I'd like to thank you
>     for this nice product! :)
>
>     I made some little changes to make it possible to set a bean on the
>     PoolingDataSource and PoolingConnectionFactory in my Spring
>     configuration instead of using driverProperties, see attached
>     changed java files, based on btm-dist-2.1.3.zip. For creating an
>     ActiveMQXAConnectionFactory bean in Spring and adding it to the
>     PoolingConnectionFactory you can now use the following Spring
>     configuration:
>
>     <bean
>        name="__activeMQConnectionFactory"
>        class="org.apache.activemq.__ActiveMQXAConnectionFactory"
>        scope="singleton"
>        destroy-method="stop"
>        >
>        <property name="brokerURL" value="vm://localhost"/>
>     </bean>
>
>     <bean
>        name="__defaultConnectionFactory"
>        class="bitronix.tm.resource.__jms.PoolingConnectionFactory"
>        init-method="init"
>        destroy-method="close"
>        >
>        <property name="uniqueName" value="${instance.name.lc
>     <http://instance.name.lc>}.__defaultConnectionFactory"/>
>        <property name="maxPoolSize" value="100" />
>        <property name="allowLocalTransactions" value="true"/>
>        <property name="resource">
>          <ref bean="__activeMQConnectionFactory"/>
>        </property>
>     </bean>
>
>     And/or using Spring to get a DataSource from JNDI and adding it to
>     the PoolingDataSource bean:
>
>     <bean
>        name="jndiDataSource"
>        class="org.springframework.__jndi.JndiObjectFactoryBean"
>        >
>        <property name="jndiName"
>     value="${jndiContextPrefix}__jdbc/${instance.name.lc
>     <http://instance.name.lc>}"/>
>     </bean>
>
>     <bean
>        name="defaultDataSource"
>        class="bitronix.tm.resource.__jdbc.PoolingDataSource"
>        init-method="init"
>        destroy-method="close"
>        >
>        <property name="uniqueName" value="${instance.name.lc
>     <http://instance.name.lc>}.__defaultDataSource"/>
>        <property name="maxPoolSize" value="20"/>
>        <property name="resource">
>          <ref bean="jndiDataSource"/>
>        </property>
>     </bean>
>
>     While searching for the mailinglist details on the website I just
>     came across the following Improvement request:
>
>     http://jira.codehaus.org/__browse/BTM-83
>     <http://jira.codehaus.org/browse/BTM-83>
>
>     Might be resolved with my changes. :)
>
>     Regards, Jaco
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email