简体   繁体   中英

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:

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 ).

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() ?

From the Javadoc for @AroundIvoke :

AroundInvoke method invocations occur within the same transaction and security context as the method on which they are interposing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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