1. Java EE 6 = Less Code + More Power
Arun Gupta, Java EE & GlassFish Guy
blogs.oracle.com/arungupta, @arungupta
1
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. The Java EE 6 Platform
Servlets 3.0 JPA 2.0 EJB 3.1 JDBC StAX
Interceptors
JSF 2.0 JAX-RS JNDI JavaMail
1.1
Bean
EJB 3.1 Lite JAXB JMS JACC
Validation1.0
JSP 2.2 CDI 1.0 JAX-WS JAXP SAAJ
Managed
JTA 1.1 JASPIC JAX-RPC ...
Beans 1.0
Contributed
by RedHat New Updated
Web Profile 1.0
4. Light-weight
● Java EE 6 Web Profile
● Pruning
● Pruned today, means
– Optional in the next release
– Deleted in the subsequent releases
● Technologies marked in Javadocs
– EJB 2.x Entity Beans, JAX-RPC, JAXR, JSR 88
8. From the real users ... Jigsaw puzzle, Modular,
standard, less xml, easy,
Developers can concentrate easy, have I said easy?
on business logic, Java EE 6 is
providing a standard for Standards compliance, vendor
the infrastructure. independence, milliseconds
and kilobyte deployment
Faster development, less
frameworks, less
complexity, more great
Higher integrated specs,
code shipped
simple and annotation driven,
single-classloader WARs,
next level of industry
standard Definite excuse to avoid
Spring forever
Simplified Java
Not your fat grandfather's Development, Focus on
enterprise Java anymore, building great products
enterprise Java renaissance
http://blogs.oracle.com/arungupta/tags/community+feedback
12. What will we do ?
1. Generate JPA Entities from the database table
2. Refactor generated entities for a more intuitive O/R mapping
3. Create an EJB for querying the database
4. Create a Servlet for testing the EJB and displaying values
from the database table
5. Enable CDI and make the EJB EL-injectable
6. Display the values in JSF2/Facelets-based view
7. Expose JPA entities as a RESTful resource by using JAX-RS
15. Java Persistence API 2
● Improved O/R mapping
● Type-safe Criteria API
● Expanded and Richer JPQL
● 2nd-level Cache
● New locking modes
● PESSIMISTIC_READ – grab shared lock
● PESSIMISTIC_WRITE – grab exclusive lock
● PESSIMISTIC_FORCE_INCREMENT – update version
● Standard configuration options
● javax.persistence.jdbc.[driver | url | user | password]
16. Create an EJB
For querying the database
CLI
JPA
Servlet EJB Database
CDI JAX-RS
JSF
17. Create an EJB – Sample Code
For querying the database
@PersistenceContext
EntityManager em;
public List<Customer> getCustomers() {
return (List<Customer>)em.createNamedQuery("Customer.findAll").getResultList();
}
18. EJB 3.1
● Simplified Packaging
● No interface view – one source file per bean
● Embeddable API
● @Singleton
● Initialization in @PostContruct
● Simplified Cron-like syntax for Timer
● Asynchronous Session Bean
● Portable Global JNDI Name
19. Create a Servlet
For testing EJB and display values from the database
CLI
JPA
Servlet EJB Database
CDI JAX-RS
JSF
20. Create a Servlet – Sample Code
For testing EJB and display values from the database
@EJB CustomerSessionBean ejb;
out.println(ejb.getCustomers());
http://localhost:8080/JavaEE6SampleApp/TestServlet
21. Servlets 3.0
● @WebServlet, @WebListener, @WebFilter, …
● Asynchronous Servlets
● @WebServlet(asyncSupported=true)
● Plugin libraries using web fragments
● Dynamic registration of Servlets
● WEB-INF/lib/[*.jar]/META-INF/resources
accessible in the root
● Programmatic authentication login/logout
● Default Error Page
● ...
22. Enable CDI
Make the EJB EL-injectable
CLI
JPA
Servlet EJB Database
CDI JAX-RS
JSF
23. Enable CDI – Sample Code
Make the EJB EL-injectable
@javax.inject.Named
24. Contexts & Dependency Injection
● Standards-based Dependency Injection
● Type-safe – Buids on @Inject API
● Context/Scope management
● Strong Typing, Loose Coupling
● Includes ELResolver
@Inject @LoggedIn User user
Request What ?
Injection Which one ?
(Qualifier) (Type)
26. Display the values
In JSF2/Facelets-based view
CLI
JPA
Servlet EJB Database
CDI JAX-RS
JSF
27. Display the values – Sample Code
In JSF2/Facelets-based view
http://localhost:8080/JavaEE6SampleApp/faces/index.xhtml
<h1>Java EE 6 Sample App</h1>
<center>Powered by GlassFish!</center>
<h:dataTable value="#{customerSessionBean.customers}" var="c">
<h:column>#{c.name}</h:column>
<h:column>#{c.customerId}</h:column>
</h:dataTable>
28. Java Server Faces 2.0
● Facelets as “templating language” for the page
● Custom components much easier to develop
● Integrated Ajax
● “faces-config.xml” optional in common cases
● Default navigation rules
● Much more …
● Runs on Servlet 2.5+
● Bookmarkable URLs
● Conditional navigation
● ...
33. Java EE for the Cloud : JSR 342
● More easily operate on private/public clouds
● Multi-tenancy
● Elasticity
● Service Provisioning
● Tighter requirements for resource/state management
● Better isolation between applications
● Potential standard APIs for NRDBMS, Caching, other
● Common management and monitoring interfaces
● Better packaging
● Evolution, not revolution
34. Java EE 7 : Technology Refresh
● Ease-of-development: JMS 2.0
● Latest web standards
● New JSRs: Web Sockets, Java JSON API
● HTTP Client API (JAX-RS 2.0)
● Possible JSRs inclusion
● Concurrency Utilities for Java EE (JSR 236)
● JCache (JSR 107)
35. Java EE 7 – When ?
● Late 2012
● Date-driven release
● Anything not ready will be deferred to Java EE 8
● Participate
● Expert Groups forming
● Public discussion lists
● JCP membership free for individuals
36. Transparency Checklist
http://jcp.org/en/resources/transparency
NEW
● EG members names
● EG business reported on a publicly
readable alias
● Schedule is public, current and updated
regularly
● Public can read/write to a wiki
● Discussion board on jcp.org
● Public read-only issue tracker
37. ● Find out what's new with Java technology
● See new tools and techniques
● Learn how to create solutions
● Network with peers
● Meet with experts
● Influence the future of the Java platform
● 400+ sessions/BoFs/HOLs
● ... oracle.com/javaone