当前位置: 首页 > news >正文

org.springframework.transaction.interceptor 类 TransactionProxyFactoryBean

转载自:这里

org.springframework.transaction.interceptor
类 TransactionProxyFactoryBean

java.lang.Object继承者 org.springframework.aop.framework.ProxyConfig继承者 org.springframework.aop.framework.AbstractSingletonProxyFactoryBean继承者 org.springframework.transaction.interceptor.TransactionProxyFactoryBean
所有已实现的接口:
java.io.Serializable, BeanClassLoaderAware, BeanFactoryAware, FactoryBean, InitializingBean

public class TransactionProxyFactoryBeanextends AbstractSingletonProxyFactoryBeanimplements FactoryBean, BeanFactoryAware

声明式事务代理简化处理工厂bean。这是一个方便的替代标准的AOP的 ProxyFactoryBean一个单独的 TransactionInterceptor定义。

这个类是为了支付交易划分典型案件的声明,即:包装用一个单身事务代理的目标对象,代理所有的接口,这个目标实现了。

有三个需要指定主要性能:

  • “transactionManager”的:该PlatformTransactionManager实施使用(例如,一个 JtaTransactionManager实例)
  • “目标”:目标对象应该是一个事务代理创建
  • “transactionAttributes”:交易属性(例如,传播行为和“只读”标志)每个目标方法名(或方法名模式)

如果“transactionManager”的属性没有明确设置这种FactoryBean运行在一个 ListableBeanFactory ,一个匹配豆型PlatformTransactionManager将获取的 BeanFactory

与此相反的TransactionInterceptor 的事务属性被指定为属性,以作为值作为键和事务属性描述方法名。方法的名字总是应用到目标类。

在内部,一个TransactionInterceptor 实例被使用,但这一类的用户并没有在意。或者,一个方法切入点可以指定会导致基础条件援引TransactionInterceptor

在“preInterceptors”和“postInterceptors”属性可以设置为添加额外的拦截器的组合,如 PerformanceMonitorInterceptorHibernateInterceptor / JdoInterceptor

提示:这个类是经常使用父/子bean定义。通常,您将定义一个抽象的交易经理父bean定义和默认的事务属性(方法名模式), 产生具体的儿童为特定目标对象的bean定义。这将减少到最低限度每bean定义的努力。

 <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <属性name="transactionManager" ref="transactionManager"/> <属性name="transactionAttributes"> <道具> <prop key="insert"> PROPAGATION_REQUIRED </道具> <prop key="update"> PROPAGATION_REQUIRED </道具> <prop key=""> PROPAGATION_REQUIRED,只读</道具> </道具> </物业> </豆> <bean id="myProxy" parent="baseTransactionProxy"> <属性name="target" ref="myTarget"/> </豆> <bean id="yourProxy" parent="baseTransactionProxy"> <属性name="target" ref="yourTarget"/> </豆>

英文注释

Proxy factory bean for simplified declarative transaction handling. This is a convenient alternative to a standard AOP ProxyFactoryBean with a separate TransactionInterceptor definition.

This class is intended to cover the typical case of declarative transaction demarcation: namely, wrapping a singleton target object with a transactional proxy, proxying all the interfaces that the target implements.

There are three main properties that need to be specified:

  • "transactionManager": the PlatformTransactionManager implementation to use (for example, a JtaTransactionManager instance)
  • "target": the target object that a transactional proxy should be created for
  • "transactionAttributes": the transaction attributes (for example, propagation behavior and "readOnly" flag) per target method name (or method name pattern)

If the "transactionManager" property is not set explicitly and this FactoryBean is running in a ListableBeanFactory, a single matching bean of type PlatformTransactionManager will be fetched from the BeanFactory.

In contrast to TransactionInterceptor, the transaction attributes are specified as properties, with method names as keys and transaction attribute descriptors as values. Method names are always applied to the target class.

Internally, a TransactionInterceptor instance is used, but the user of this class does not have to care. Optionally, a method pointcut can be specified to cause conditional invocation of the underlying TransactionInterceptor.

The "preInterceptors" and "postInterceptors" properties can be set to add additional interceptors to the mix, like PerformanceMonitorInterceptor or HibernateInterceptor / JdoInterceptor.

HINT: This class is often used with parent / child bean definitions. Typically, you will define the transaction manager and default transaction attributes (for method name patterns) in an abstract parent bean definition, deriving concrete child bean definitions for specific target objects. This reduces the per-bean definition effort to a minimum.

 <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"abstract="true"><property name="transactionManager" ref="transactionManager"/><property name="transactionAttributes"><props><prop key="insert*">PROPAGATION_REQUIRED</prop><prop key="update*">PROPAGATION_REQUIRED</prop><prop key="*">PROPAGATION_REQUIRED,readOnly</prop></props></property></bean><bean id="myProxy" parent="baseTransactionProxy"><property name="target" ref="myTarget"/></bean><bean id="yourProxy" parent="baseTransactionProxy"><property name="target" ref="yourTarget"/></bean>

从以下版本开始:
21.08.2003
作者:
Juergen Hoeller, Dmitriy Kopylenko, Rod Johnson
另请参见:
setTransactionManager(org.springframework.transaction.PlatformTransactionManager), AbstractSingletonProxyFactoryBean.setTarget(java.lang.Object), setTransactionAttributes(java.util.Properties), TransactionInterceptor, ProxyFactoryBean, 序列化表格

http://www.lryc.cn/news/570921.html

相关文章:

  • VS2013+MFC 简易音乐播放器
  • 电商导购系统的基本架构与设计
  • 【习题解析】田忌赛马
  • linux设备树dts文件详解
  • matlab axis函数_MATLAB二维图形
  • HTML网页一键变黑白色调
  • Source Insight的入门使用
  • 网页鼠标点击特效案例收集
  • 如何使用十进制range()步长值?
  • python升级pip怎么出错了_Python,开启吐槽模式,新手必看!
  • linux命令chm app,Linux常用命令全集
  • 拼音缩写是啥意思_NMSL?AWSL?这些拼音缩写到底是啥意思?
  • Package name is not valid . ‘import‘ is not a valid Java identifier
  • mysql修改密码笔记
  • 如何用计算机cmd算数,计算命令:怎么在CMD的计算器命令是什么?
  • 小四哥的故事——访中联绿盟陈庆
  • 山寨qq java_MTK手机QQjava版本山寨qq2009通用版
  • 服务器重装
  • 计算机网络——用telnet登录qq邮箱给人发邮件
  • 1.2数组的基本算法设计
  • Minecraft-服务器领地(Residence插件)
  • 状态模式State Pattern
  • Myeclipse 10安装与激活
  • 性能测试——性能测试-常见性能指标-总体概况
  • 1KB快捷方式病毒的解决方法
  • C# 零基础搭建一个简单的Asp.Net Core WebAip服务
  • 当他成为SKY ——李晓峰
  • 5.5.2_2并查集的进一步优化
  • Cult3D高级教程——1.技术综合篇
  • sql脚本导入sql_学习SQL:SQL脚本