Bitronix and Spring

View: New views
3 Messages — Rating Filter:   Alert me  

Bitronix and Spring

by Frederic Conrotte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

First of all, thanks for making BTM open source, IMHO it's really easier to use than JOTM or Jencks.

Within the spring context config file, you dont need to specify "depends-on" argument on bitronixTransactionManager because BTM works mostly statically, therefore Spring beans lifecycle does not matter

http://docs.codehaus.org/display/BTM/Spring+Framework13

    <bean id="bitronixTransactionManager" factory-method="getTransactionManager"
          class="bitronix.tm.TransactionManagerServices" destroy-method="shutdown" />

Just a question, why did you design BTM using static instances and methods ?

Fred

Re: Bitronix and Spring

by Ludovic Orban :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Thanks for your kind words. I hope you appreciate the hard work spent building BTM.

Regarding Spring and its dependencies it's quite the contrary: you need to specify a 'depends-on' attribute betwen the TM bean and the config bean or Spring won't know when to initialize the config as it's not injected in the TM.

With static instances and methods I guess you're speaking about the TransactionManagerServices class. I fully agree this design is not optimal but I decided to go with this trade off to maximize BTM's ease of use.

When you're using Spring it's quite easy to inject the config in the TM and the TM in the connection pools and recoverer but nevertheless error prone, and not even speaking about the task scheduler, the disk journal, the 2PC executor and the resource loader. When not using Spring this quickly becomes a nightmare: it's all too easy to forget about one or to get lost in all those dependencies.

I've primarily built BTM for my own needs and I did find that manually managing dependencies between all those services was a hassle, so I quickly concluded it would be a nightmare for other people.

Re: Bitronix and Spring

by Frederic Conrotte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ludovic Orban wrote:
Thanks for your kind words. I hope you appreciate the hard work spent building BTM.
For sure !

Ludovic Orban wrote:
Regarding Spring and its dependencies it's quite the contrary: you need to specify a 'depends-on' attribute betwen the TM bean and the config bean or Spring won't know when to initialize the config as it's not injected in the TM.
You're right, the dependency is about instances returned by factory methods, not bitronix.tm.TransactionManagerServices itself.

so

<!-- create BTM transaction manager -->
<bean id="BitronixTransactionManager" factory-method="getTransactionManager"
        class="bitronix.tm.TransactionManagerServices" depends-on="btmConfig" destroy-method="shutdown" />

is correct