简体   繁体   English

Java EE拦截器是否参与EJB的容器管理事务

[英]Do Java EE interceptors take part in container managed transactions of an EJB

Somehow this piece of information seems to be missing in the usual Java EE documentatation resources: 通常,Java EE文档资源中似乎以某种方式缺少此信息:

Unless there is an external transaction active, the container starts a new transaction when calling a business method of an EJB with container managed transactions, if this business method is assigned a transaction attribute that requires a transaction (eg TransactionAttributeType.REQUIRED ). 除非有活动的外部事务,否则,如果为该业务方法分配了需要事务的事务属性(例如TransactionAttributeType.REQUIRED ),则在使用容器管理的事务调用EJB的业务方法时,容器将启动新事务。

Now, if this method call is intercepted by a method interceptor 现在,如果此方法调用被方法拦截器拦截

@AroundInvoke
public Object onMethodCall(InvocationContext ctx) throws Exception
{
  doSomethingBefore();
  ctx.proceed();
  doSomethingAfterwards();
}

Will the methods doSomethingBefore() and doSomethingAfter() be called within this new transaction context, or will the transaction be restricted to the call ctx.proceed() ? 方法doSomethingBefore()doSomethingAfter()是在此新事务上下文中调用的,还是将事务限制为调用ctx.proceed()

From the Javadoc for @AroundIvoke : 从Javadoc中获取@AroundIvoke

AroundInvoke method invocations occur within the same transaction and security context as the method on which they are interposing. AroundInvoke方法调用与它们所插入的方法在同一事务和安全上下文中发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM