<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <link rel="stylesheet" href="css/stdlayout.css" type="text/css"> <link rel="stylesheet" href="css/print.css" type="text/css"> <meta content="text/html; charset=Big5" http-equiv="content-type"> <title>TransactionAttributeSource、 TransactionAttribute</title></head><body><h3><a href="http://caterpillar.onlyfun.net/Gossip/index.html">FromGossip@caterpillar</a></h3><h1><a href="SpringGossip.html">Spring Gossip: TransactionAttributeSource、 TransactionAttribute</a></h1><table style="text-align: left; width: 946px; height: 32px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="vertical-align: top; width: 250px; text-align: center;"> <!--google_ad_client = "";google_ad_width = 160;google_ad_height = 600;google_ad_format = "160x600_as";google_ad_type = "text_image";google_ad_channel = "";//--> <br> <br> <!--google_ad_client = "";google_ad_width = 160;google_ad_height = 600;google_ad_format = "160x600_as";google_ad_type = "text_image";google_ad_channel = "";//--> </td> <td style="vertical-align: top; width: 690px; text-align: left;"> <small>在TransactionProxyFactoryBean上有setTransactionAttributeSource()與setTransactionAttributes()方法,它們是用來設定交易屬性的策略實例。<br> <br>org.springframework.transaction.interceptor.TransactionAttributeSource介面上有一個getTransactionAttribute()方法,您可以根據傳遞給它的Method實例與Class實例,決定該返回一個什麼內容的org.springframework.transaction.interceptor.TransactionAttribute實例,一個最簡單的TransactionAttributeSource實作是org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource,對於每一個方法呼叫都會應用交易,它會返回的TransactionAttribute實例之預設傳播行為是PROPAGATION_REQUIRED,隔離層級為ISOLATION_DEFAULE。<br> <br>一個應用的例子如下所示:<br> </small> <div style="margin-left: 40px;"><small style="font-weight: bold; font-family: Courier New,Courier,monospace;">...</small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"><bean id="transactionAttributeSource"</small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> class="org.springframework.transaction.interceptor.</small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> → MatchAlwaysTransactionAttributeSource"/></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"><bean id="userDAOProxy"</small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> class="org.springframework.transaction.</small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> → interceptor.TransactionProxyFactoryBean"></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <property name="proxyInterfaces"></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <list></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <value>onlyfun.caterpillar.IUserDAO</value></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> </list></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> </property></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <property name="target"></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <ref bean="userDAO"/></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> </property></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <property name="transactionManager"></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <ref bean="transactionManager"/></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> </property></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <property name="transactionAttributeSource"></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <ref bean="transactionAttributeSource"/></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"> </property></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-weight: bold; font-family: Courier New,Courier,monospace;"></bean></small><br> </div> <small>...<br> <br> <br>您可以使用org.springframework.transaction.interceptor.DefaultTransactionAttribute,並設置自己的交易策略,之後將之設定給TransactionAttributeSource,例如:<br> </small> <div style="margin-left: 40px;"><small style="font-family: Courier New,Courier,monospace;"><span style="font-weight: bold;">...</span></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-family: Courier New,Courier,monospace;"><span style="font-weight: bold;"><bean id="myTransactionAttribute"</span></small><br style="font-weight: bold; font-family: Courier New,Courier,monospace;"> <small style="font-family: Courier New,Courier,monospace;"><span style="font-weight: bold;"> class="org.springframework.transaction.</span></small><br style="font-weight: bold; font-family: Courier Ne
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
学习spring的很好的参考资料——Spring Gossip (118个子文件)
beanlc.bmp 299KB
print.css 3KB
stdlayout.css 2KB
Thumbs.db 36KB
TransactionAttributeSource.html 36KB
JdbcTemplateExecuteUpdate.html 25KB
JDBCDeclarativeTransaction.html 24KB
SpringGossip.html 24KB
SpringDAO.html 22KB
Bind.html 21KB
HandlerMapping.html 20KB
TilesExample.html 19KB
MultiActionController2.html 19KB
ViewResolver.html 19KB
TransactionAttribute.html 16KB
Validator.html 16KB
JdbcTemplateQuery.html 16KB
CollectionInjection.html 16KB
StrutsSpring.html 16KB
DataSource.html 15KB
DI.html 14KB
AbstractWizardFormController.html 14KB
FirstSpringMVC.html 14KB
PointcutCU.html 13KB
IOC.html 13KB
FirstHibernate.html 12KB
JDBCProgrammaticTransaction.html 12KB
WebApplicationContext.html 11KB
HandlerInterceptor.html 11KB
ObjectCRUD.html 11KB
Type2Type3.html 10KB
ThrowawayController.html 10KB
SpringTransform.html 10KB
SessionFactoryInjection.html 10KB
Controller.html 10KB
FromProxyToAOP.html 9KB
ParameterizableViewController.html 9KB
UseQuartz.html 9KB
ThrowAdvice.html 9KB
SpringTransaction.html 9KB
FileUpload.html 9KB
PropertyEditor.html 9KB
HibernateTemplate.html 9KB
JSFSpring.html 9KB
AbstractController.html 8KB
FirstJSF.html 8KB
RegExpMethodPointcutAdvisor.html 8KB
HessianBurlap.html 8KB
BeforeAdvice.html 8KB
ExceptionResolver.html 8KB
DelegatingIntroductionInterceptor.html 8KB
NameMatchMethodPointcutAdvisor.html 8KB
IntroductionInterceptor.html 8KB
SimpleFormController.html 8KB
AOPConcept.html 7KB
Pointcut.html 7KB
RMI.html 7KB
MultiActionController1.html 7KB
AutoWiring.html 7KB
FirstStruts.html 7KB
BeanPostProcessor.html 7KB
FirstSpring.html 7KB
AroundAdvice.html 7KB
BeanLifeCycle.html 7KB
HibernateDeclarativeTransaction.html 6KB
ControlFlowPointcut.html 6KB
ModelAndView.html 6KB
AbstractCommandController.html 6KB
SpringBind.html 6KB
CustomEditorConfigurer.html 6KB
DynamicProxy.html 6KB
AfterAdvice.html 5KB
AttachedFileMail.html 5KB
HttpInvoker.html 5KB
JSTL.html 5KB
PublishEvent.html 5KB
ReplaceDataSource.html 5KB
AwareInterface.html 5KB
BeanDefWithoutXML.html 5KB
PropertyPlaceholderConfigurer.html 5KB
MessageResource.html 5KB
AbstractFormController.html 5KB
ViewClass.html 5KB
RefBean.html 5KB
UseTimerTask.html 5KB
BeanFactoryPostProcessor.html 4KB
SpringMessage.html 4KB
DefaultAdvisorAutoProxyCreator.html 4KB
UseJdbcTemplate.html 4KB
SpringABC.html 4KB
MethodInvokingJobDetailFactoryBean.html 4KB
HibernateProgramaticTransaction.html 4KB
MethodInvokingTimerTaskFactoryBean.html 4KB
BeanFactoryApplicationContext.html 4KB
BeanNameAutoProxyCreator.html 3KB
PropertyOverrideConfigurer.html 3KB
ApplicationListener.html 3KB
HTMLMail.html 3KB
Resource.html 3KB
SimpleMail.html 3KB
共 118 条
- 1
- 2
wxslue
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0