The document provides an overview of the new features in the Java EE 6 platform, including new APIs, the Web Profile specification, improved extensibility, and highlights of APIs like JAX-RS and EJB 3.1. It summarizes the key components and extension points included in the Web Profile and describes how the platform focuses on pluggability, modular web applications, and common design patterns across APIs.
Overview of Java EE 6 by Roberto Chinnici at SFJUG
1. <Insert Picture Here>
An Overview of the Java EE 6 Platform
Roberto Chinnici
Java EE Platform Lead
2. The following is intended to outline our general
product direction. It is intended for information
purposes only, and may not be incorporated into any
contract. It is not a commitment to deliver any
material, code, or functionality, and should not be
relied upon in making purchasing decisions.
The development, release, and timing of any
features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.
3. Agenda
• What's new in Java EE 6?
• Web Profile
• Extensibility
• Highlights from some of the new APIs
8. Web Profile
• First Java EE profile to be defined
• A fully-functional, mid-size stack for modern web
application development
• Complete, but not the kitchen sink
9. Java EE 6 Web Profile Contents
JSF 2.0
JSP 2.2 · EL 2.2 · JSTL 1.2 · JSR-45 1.0
Servlet 3.0
EJB 3.1 Lite · DI 1.0 · CDI 1.0 · Managed Beans 1.0
Bean Validation 1.0 · Interceptors 1.1 · JSR-250 1.1
JPA 2.0 · JTA 1.1
10. Java EE 6 Web Profile Extension Points
JSF 2.0
JSP 2.2 · EL 2.2 · JSTL 1.2 · JSR-45 1.0
Servlet 3.0
EJB 3.1 Lite · DI 1.0 · CDI 1.0 · Managed Beans 1.0
Bean Validation 1.0 · Interceptors 1.1 · JSR-250 1.1
JPA 2.0 · JTA 1.1
11. Pluggability/Extensibility
• Focus on the web tier in this release
• Create a level playing field for third-party frameworks
• Simplify packaging of web applications
12. Modular Web Applications
• Libraries can contain /META-INF/web-fragment.xml
• web.xml is optional
• @WebServlet, @WebFilter annotations
• ServletContainerInitializer interface
• Programmatic registration of components
• Resource jars containing /META-INF/resources
/WEB-INF/lib/catalog.jar
/META-INF/resources/catalog/books.html
→ http://myserver:8080/myapp/catalog/books.html
14. Sample Web Fragment Descriptor
<web-fragment
version=”3.0”
xmlns="http://java.sun.com/xml/ns/javaee">
<servlet>
<servlet-name>welcome</servlet-name>
<servlet-class>WelcomeServlet</servlet-class>
</servlet>
<listener>
<listener-class>RequestListener</listener-class>
</listener>
</web-fragment>
15. Strategy for Evolving the APIs
• Capture common patterns
• Fix inconsistencies
• Adopt what works
• Make APIs work better together
• Reducing boilerplate/packaging
• Be transparent
16. JAX-RS 1.1
• RESTful web services API
• Already widely adopted
• Really a general, high-level HTTP API
• Annotation-based programming model
• Programmatic API when needed
18. Building HTTP Responses
return Response.created(createdUri)
.entity(createdContent)
.build();
return Response.status(404)
.entity(message)
.type("text/plain")
.build();
Similarly, use UriBuilder to build URIs
19. EJB 3.1
• @Singleton beans
• @Startup beans
• Declarative timers
• Asynchronous method calls
@Asynchronous public Future<Integer> compute();
• Define EJBs directly inside a web application
• EJBContainer API works on Java SE
20. EJB 3.1 Code Snippets
@Singleton @Startup
public class StartupBean {
@PostConstruct
public void doAtStartup() { … }
}
@Stateless public class BackupBean {
@Schedule(dayOfWeek=”Fri”, hour=”3”, minute=”15”)
public void performBackup() { … }
}
@Stateless public class CacheRefreshingBean {
@Schedule(minute=”*/5”, persistent=false)
public void refreshCache() { … }
}
21. EJB 3.1 Lite
• A subset of EJB 3.1
• All types of session beans (stateful, stateless, singletons)
• Local access only
• Declarative transactions and security
• Interceptors
• ejb-jar.xml descriptor optional
22. Java EE 6 Web Profile Core Component Model
JSF 2.0
JSP 2.2 · EL 2.2 · JSTL 1.2 · JSR-45 1.0
Servlet 3.0
EJB 3.1 Lite · DI 1.0 · CDI 1.0 · Managed Beans 1.0
Bean Validation 1.0 · Interceptors 1.1 · JSR-250 1.1
JPA 2.0 · JTA 1.1
23. Dependency Injection
• DI + CDI (JSR-330 + JSR-299)
• @Resource still around for container resources
@Resource DataSource myDB;
• Added @Inject annotation for type-safe injection
@Inject @LoggedIn User user;
• Automatic scope management (request, session, etc.)
• No configuration: beans discovered at startup
• Extensible via the BeanManager API
24. Scoped Bean with Constructor Injection
@ApplicationScoped
public class CheckoutHandler {
@Inject
public CheckoutHandler(
@LoggedIn User user,
@Reliable @PayBy(CREDIT_CARD)
PaymentProcessor processor,
@Default ShoppingCart cart) {…}
}
Injection points identified by Qualifier + Type
@Default qualifier can be omitted
25. Why Use CDI?
• Structure the application as a set of beans
• Injection and events enable decoupling
– No direct dependency between beans
– Freedom to refactor the code, change implementations
• Automatic state management base on scope
• Support EJB components and plain “managed beans”
• Beans discovered automatically - no configuration
needed
• Extensible notion of bean
– Can incorporate components from external frameworks
26. Java EE 6 Platform
• More powerful
• More flexible
• More extensible
• Easier to use
http://www.oracle.com/javaee