编程BMT-UserTransaction [英] Programming BMT - UserTransaction

查看:130
本文介绍了编程BMT-UserTransaction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于UserTransaction接口的BMT的完整编程吗?换句话说,如果我想使用BMT,在任何情况下我需要的服务要比UserTransaction接口提供的服务更多.

Is the complete programming of BMT based on UserTransaction interface? In other words, if I want to use BMT, is there any scenario when I would require more services than those provided by the UserTransaction interface.

为什么要问这个问题?如果我使用事务管理器的其他实现(例如Bitronix TM或Atomikos)而不是容器提供的默认设置,是否足以将新的TM注入UserTransaction对象中?

Why this question? If I use a different implementation of the transaction manager (such as Bitronix TM or Atomikos) and not the default provided by the container, is it just enough to inject the new TM into UserTransaction object?

-谢谢

推荐答案

这实际上仅限于应用服务器本身所允许的范围;即是否明确支持替换交易管理器.

This is really limited to what the app server itself will allow; i.e. if it explicitly supports replacing the transaction manager.

事务管理的真正技巧是通过使用

The real art to transaction management is the container registering transactional resources (DataSource connections, JMS Sessions, JPA EntityManagers, etc) with the TransactionManager via wrapping them with Synchronization objects and registering them with the current transaction via either the Transaction or the TransactionSynchronizationRegistry

容器实现Synchronization对象,TransactionManager实现TransactionTransactionSynchronizationRegistry对象.两者之间的协调是在事务运行时为您提供实际管理的条件.

The container implements the Synchronization objects, the TransactionManager implements the Transaction and TransactionSynchronizationRegistry objects. The coordination between the two is what gives you actual management when a transaction is running.

BMT和CMT只是告诉容器启动/停止事务的替代方法.在某些方面,"Bean-Managed"一词是错误的,因为每个兼容的应用服务器中的UserTransaction将由容器实现,因此仍由容器来完成.同样,容器管理的"有点误导,因为它仍然是bean开发人员决定何时开始/停止事务的时间,它只是以声明方式还是以编程方式来完成.这些功能的最准确描述是程序管理的事务和声明式管理的事务.在所有情况下,仍然是bean与容器对话,容器和事务管理器负责所有工作.

BMT and CMT are just alternate ways to tell the container to start/stop transactions. In some regards the term "Bean-Managed" is false as the UserTransaction in every compliant app server will be implemented by the container and thus it is still the container doing the work. As well "Container-Managed" is slightly misleading as it is still the bean developer deciding when transactions are started/stopped, it's just done declaratively vs programmatically. The most accurate description of these features would be Programmatically-Managed Transactions and Declaratively-Managed Transactions. In all cases it is still the bean talking with the container and the container and transaction manager doing all the work.

所有这些都表明您仍然可以更改事务管理器,OpenEJB和TomEE支持它,但是它不能以您尝试的方式工作.请与您的供应商联系,以查看是否可行.

All that said it may still be possible for you to change the transaction manager, OpenEJB and TomEE support it, however it will not work in the way you are attempting. Check with your vender to see if this is possible.

这篇关于编程BMT-UserTransaction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆