- CDI extension for JTA
This CDI portable extension provides support for JTA (Java Transaction API) transactions in your Helidon MicroProfile applications.
Maven Coordinates
To enable JTA Support add the following dependency to your project’s pom.xml (see Managing Dependencies).
<dependency>
<groupId>io.helidon.integrations.cdi</groupId>
<artifactId>helidon-integrations-cdi-jta-weld</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<scope>provided</scope>
</dependency>Declaring a method to be transactional
The following example shows how to declare a transactional method.
@Transactional(Transactional.TxType.REQUIRED)
public void doSomethingTransactionally() {
}The extension ensures that a transaction is started before and committed after the method executes. If the method throws an exception, the transaction will be rolled back.
You can further specify the transactional behavior of the extension by using different instances of the Transactional annotation. For more information, see the Transactional annotation documentation.
Transactional method support is implemented by CDI interception facilities. Among other things, this means that the method to which you apply the Transactional annotation must not be private and must in all other ways be a business method. See the Java Interceptors specification for more details.
During a transactional method invocation, the extension makes the following objects available for injection via the Inject annotation: