Thursday May 24, 2012

Transactional Interceptors

As part of our goal of aligning managed bean technology across the Java EE Platform, one of the improvements we've targeted for Java EE 7 is a JTA transactional interceptor facility. The intent here is to bring the ease of use of EJB's "container-managed" transactions to the platform as a whole via a more general solution based on CDI interceptors so that these would be usable both by CDI managed beans and other Java EE components. There has been large-scale support for this direction from members of the Java EE 7 Platform Expert Group.

To achieve this, we plan to add an annotation and standardized values in the javax.transaction package. For example:

@Inherited
@InterceptorBinding
@Target({TYPE, METHOD})
@Retention(RUNTIME)
public @interface Transactional {
   TxType value() default TxType.REQUIRED
}

public enum TxType {
   REQUIRED,
   REQUIRED_NEW,
   MANDATORY,
   SUPPORTS,
   NOT_SUPPORTED,
   NEVER
}


public class ShoppingCart {
   ...
   @Transactional
   public void checkOut() {...}
   ...
}

Our plan is to define the semantics of the corresponding interceptor classes as part of an update to the JTA spec. This work will be done under the Java EE 7 umbrella as part of the JTA spec project on java.net.

The hard part, as usual, will be nailing down the details.

A point on which we've had considerable discussion (but haven't yet converged) has to do with how the exceptions which reach a transactional interceptor affect the transaction in progress.

  • Do they always cause rollback?
  • Do they never cause rollback?
  • Do they cause rollback only if they are runtime exceptions?
  • Do they cause rollback unless this behavior is overridden by annotations?
  • Do they never cause rollback unless this behavior is overridden by annotations?
  • If the overriding of behavior is configurable by annotations, what form do these annotations take?

While most members of the Java EE 7 Expert Group agree that some exceptions should result in the current transaction being marked for rollback, there is a wide range of opinion as to how this should best be made configurable. You can read the details of our discussion on the thread that starts here.

Before trying to resolve this, we'd really like to get feedback from more of the developer community. You can help contribute to this discussion by posting your input here, by joining the users@javaee-spec.java.net email list on the Java EE spec project and adding to the thread, and/or by joining the JTA spec project.

Thanks!

About

Linda DeMichiel is the Specification Lead for Java EE 7 and for Java Persistence 2.1, and a member of the Java Platform, Enterprise Edition team at Oracle. She was formerly the Specification Lead for JPA 2.0 and for EJB 3.0.

Search

Top Tags
Categories
Archives
« May 2012 »
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
25
26
27
28
29
30
31
  
       
Today