Given the functionality of a transaction manager to set the transaction
timeout [1]. I would like to expose this feature in a spec defined manner.
How about the following annotation:
@Target({METHOD, TYPE})
@Retention(RUNTIME)
public @interface TransactionAttribute {
TransactionAttributeType value() default
TransactionAttributeType.REQUIRED;
long timeout() default -1L;
TimeUnit unit() default TimeUnit.SECONDS;
}
Where -1 means unspecified.
And the following descriptor fragment:
<ejb-jar version="3.2">
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>A</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>RequiresNew</trans-attribute>
<trans-timeout>
<timeout>10</timeout>
<unit>Seconds</unit>
</trans-timeout>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
What do you guys think?
Carlo
[1]
http://docs.oracle.com/javaee/6/api/javax/transaction/TransactionManager.html#setTransactionTimeout%28int%29
PS. Since people are going to dig, we discussed changing transaction
attributes on Oct 17th 2007.