Java Platform, Enterprise Edition 7 (Java EE 7)
JSR-342 is the umbrella specification ties together the various subsystems which compose the platform, and provides additional integration support. The Java EE 7 platform added the following new APIs to previous version of the platform:
- Batch Applications for the Java Platform (1.0)
- Java API for WebSocket (1.0)
- Java API for JSON Processing (1.0)
- Concurrency Utilities for Java EE (1.0)
Also the following APIs have also been significantly updated to help simplify building enterprise applications with Java:
- Java Message Service (2.0)
- Contexts and Dependency Injection (1.1)
- Java Persistence API (2.1)
- Java Transaction API (1.2)
Adds 2 important new features : @Transactional and @TransactionScoped - Java Server Faces (2.2)
- Java API for RESTful Web Services (2.0)
- Bean Validation (1.1)
- Servlet (3.1)
Java Transaction API (1.2)
The new @Transactional annotation solve this by basically bringing the semantics of those EJB transaction attributes in managed beans without any dependencies on the EJB container. So the @Transactional annotation provides the ability to declaratively control transaction boundaries on managed beans. Under the hood, this capability is provided by a CDI interceptor that handle the necessary transaction plumbings (suspend, resume, commit, …). In a nutshell, @Transactional bring the ease of CMT transactions to various Java EE Components (Servlet, JAX-RS, etc.) without requiring to use EJBs.
The new @TransactionScoped annotation provides the ability to specify a standard CDI scope to define bean instances whose lifecycle is scoped to the currently active JTA transaction. This simple code driven post explain and demonstrate such a behaviour in action.
package com.espalier.javaee7.bean; import java.util.Random; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.transaction.TransactionScoped; @TransactionScoped public class TestTransactionalScopeBean implements TestTransactionalScope { private static final long serialVersionUID = 1L; private long value; @PostConstruct private void init() { value = System.currentTimeMillis(); System.out.println("TestTransactionalScopeBean initialized. Value is " + value); } @PreDestroy private void destroy() { System.out.println("TestTransactionalScopeBean destroyed. Value is " + value); } @Override public long getValue() { return value; } } |
Example Links
- Cargo Tracker
Applied domain-driven design blueprints for Java EE - Wildfly Quickstart
Quickstarts demonstrate WildFly, Java EE 7 and a few additional technologies.
They provide small, specific, working examples that can be used as a reference.
Leave a Reply
You must be logged in to post a comment.