2. <Insert Picture
Here>
Future of Java EE
Jerome Dochez
Glassfish Architect
3. The following is intended to outline our general product
direction. It is intended for information purposes, 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
4. Java EE and… the Cloud?
• Containers are back in vogue!
4
5. Java EE and… the Cloud?
• We have containers...
• We have services… injectable services…
• We scale to large clusters…
• We have a security model…
5
6. Java EE for the Cloud
• Tighter requirements for resource and
state management
• Better isolation between applications
• Potential standard APIs for NRDBMS,
caching, other
• Common management and monitoring
interfaces
• Evolution, not revolution
6
7. Better Packaging for the Cloud
• Apps are versioned
• Multiple versions can coexist
• Must deal with data versioning,
upgrades, etc.
• Need ability to specify QoS properties
• Apps both expose and connect to
services
7
8. Cloud Platform
Application
Java Persistence Queueing
…
Service Service Service
State Management
Virtualization Layer
8
9. Cloud Platform
Application
Code Code Code QoS
Schema Migration Security …
Module Module Module Information
Java Persistence Queueing
…
Service Service Service
State Management
Virtualization Layer
9
10. Cloud Platform
Application Application Application
Java Persistence Queueing
…
Service Service Service
State Management
Virtualization Layer
10
11. Cloud Platform
Application Application Application Application Application
Java Persistence Queueing
…
Service Service Service
State Management
Virtualization Layer
11
12. Cloud Platform
Managed Environment
Application Application Application Application Application
Java Persistence Queueing
…
Service Service Service
State Management
Virtualization Layer
12
13. Demo Application
JSF EJB/
Browser CDI JPA
Database
EJB
Timer
REST JPA
Client
Jersey Client
API
14. Modularity
• Build on Java SE work
• Applications made of modules
• Dependencies are explicit
• Versioning is built-in
• Classloaders straightened out
14
23. JSF 2.1: short term
• Transient State Saving
• UIData Transient state saving
• XML view cleanup
• Facelets Cache API
• “XML free” in specification
23
24. JSF 2.2
• HTML5
– semantic tags
– support of browser feature detection
– HTML5 for components
– Audio and video
– Standardize popular API (Trinidad’s page
resolver, ADF ApplicationContectManager)
– JSR-276, tools support
– Enhancements to existing features
• mobile renderkits
• composite components
24
25. JMS
• Resolve ambiguities and uncertainties in the
APIS
– Remove complexities in the existing API
– Incomplete and optional integration in Java EE env.
• Standardize common vendor extensions/
features
• Integration with other specs and non-Java
languages
• Expand JMS spec with new developments in
messaging
25
26. Web Tier
• Web socket support
• Standard JSON API
• HTML5 support
• NIO.2-based web container
26
27. Web Socket Sample
(with Grizzly WebSocket API)
public class ChatApplication
extends WebSocketApplication<ChatWebSocket> {
protected ChatWebSocket createWebSocket(Connection c,
ServerWebSocketMeta m)
{ return new ChatWebSocket(c, m, this); }
public void onMessage(ChatWebSocket s, DataFrame frame) {
String msg = frame.getAsText();
s.sendJson(s.getUser(), msg);
}
public void onClose(ChatWebSocket s) {
s.sendJson(“system”, s.getUser() + “ left the chat”);
}
}
27
28. Async Web Sample (Atmosphere)
Java EE 8
@Path("/{topic}")
@Produces("text/plain;charset=ISO-8859-1")
public class PubSub {
private @PathParam("topic") Broadcaster topic;
@GET @Suspend
public Broadcastable subscribe() {
return new Broadcastable("",topic); }
@POST @Broadcast
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Broadcastable publish(
@FormParam("message") String message) {
return new Broadcastable(message,topic);
}
28
29. Java Persistence 2.1
• Build on functionality added in JPA 2.0
• Features largely driven by community input
• Infilling for
– Improved standardization
– Improved flexibility
2
30. Java Persistence 2.1 Candidate Features
O/R Mapping and Modeling
• Converters / custom types
• “Fetch” plans / profiles
• Additional mapping metadata
• User-defined naming strategies
• More flexibility in use of generated values
• Immutable attributes; readonly entities
• More flexible XML descriptors
3
31. Java Persistence 2.1 Candidate Features
API Enhancements
• Additional event listeners and callbacks
• Improved control of persistence context
synchronization
• Support for dynamic definition of persistence unit
• Extension of Metamodel API to ORM
• Methods for dirty detection
• Additional unwrap methods
4
32. Java Persistence 2.1 Candidate Features
Enhancements to Query Functionality
• Support for stored procedures
• Additional built-in functions
• Database and vendor function invocation
support
• Downcasting
• Outer joins with ON conditions
• Update and delete criteria queries
• Mapping between JPQL and criteria queries
• Improved result type mapping for native
queries
5
33. JPA 2.1 Rollout
• Targeted as part of Java EE 7 + standalone
• Plan to file JSR this year
– Expert Group formation in January 2011
• Timelines for Java EE 7 may impact contents
of JPA 2.1
– Expert Group will need to prioritize
– Community input a very important factor here
jsr-317-feedback@sun.com
6
34. JAX-RS status
• JAX-RS 1.0: 18th October 2008
• JAX-RS 1.1: 23rd November 2009
– Aligned with Java EE 6, but not in the Web profile!
• JAX-RS 2.0: Future<?>
– Draft JSR 12th November 2010
– Like to submit to JCP in December
– http://bit.ly/bkXtay
• Implementations
– Apache CXF, Apache Wink, eXo, Jersey, RESTEasy,
Restlet, Triaxrs
1
34
35. The Future<?>
• JAX-RS 1.0 is 2 years old
• JAX-RS implementations have innovated in that
2 year period... and other frameworks
– Play, SiteBricks, Scalate, Spring, VRaptor
• JAX-RS 2.0 should take innovations that work
well and standardize
– Premature standardization is a root of evil
2
35
36. List<Future<?>>
• Client API
– Low level builder pattern
– High level response matching
• Model View Controller
– Using JSPs and Scalate
• Asynchronous interactions
– Using Atmosphere for HTTP streaming
3
36
37. List<Future<?>>
• Hypermedia
• Improved @Inject integration
• Parameter validation
– Using Bean Validation API (JSR-303)
• Improve ease of use
– DRY
– Convention over configuration
4
37
38. Improved @Inject integration
• JAX-RS was specified before JSR 330 was
started
• Use @Inject for all injection targets
– Some progress made with CDI integration
• Enable injection targets for methods that JAX-
RS runtime invokes
– resource methods, sub-resource methods and sub-
resource locators
5
38
39. Standard injection declarations
public class Foo {
@Context UriInfo ui;
@Context
public setRequest(Request r) { … }
public Foo(@QueryParam("x") int x) { … }
}
6
39
40. Replace @Context with @Inject
public class Foo {
@Inject UriInfo ui;
@Inject
public setRequest(Request r) { … }
@Inject
public Foo(@QueryParam("x") int x) { … }
@Inject SomeOtherDependency o;
}
7
40
41. Replace @Context with @Inject
public class Foo {
@Inject UriInfo ui;
@Inject
public setRequest(Request r) { … }
@Inject
public Foo(@QueryParam int x) { … }
@Inject SomeOtherDependency o;
}
8
41
42. Supported now with CDI
@RequestScoped
public class Foo {
@Inject UriInfo ui;
@Inject
public setRequest(Request r) { … }
public Foo() {}
@Inject
public Foo(@QueryParam("x") int x) { … }
@Inject SomeOtherDependency o;
}
9
42
43. Targets for invoked methods
public class Foo {
@Inject SomeOtherDependency o;
@GET
public String post(
String s, // Request entity is not annotated
@Context UriInfo ui,
@? SomeOtherDependency o) { ... }
}
1
0 43
44. Targets for invoked methods
public class Foo {
@Inject SomeOtherDependency o;
@GET
public String post(
String s, // Request entity is not annotated
@Context UriInfo ui,
@? SomeOtherDependency o) { ... }
}
1
1 44
45. Annotate non-entity parameters?
public class Foo {
@Inject SomeOtherDependency o;
@GET
public String post(
String s,
@InjectParam UriInfo ui,
@InjectParam SomeOtherDependency o) { ... }
}
1
2 45
46. Annotate entity parameter?
public class Foo {
@Inject SomeOtherDependency o;
@GET
public String post(
@Entity String s,
UriInfo ui,
SomeOtherDependency o) { ... }
}
1
3 46
47. Future<Future<?>>
• Asynchronous interactions with the Atmosphere
framework
– Long polling, HTTP streaming and WebSocket
– Leverages JAX-RS and Jersey for a high-level
programming model
1
4 47
48. Pub/Sub example
@Path("/{topic}")
@Produces("text/plain")
public class PubSub {
private @PathParam("topic") Broadcaster topic;
@Suspend @GET
public Broadcastable subscribe() {
return new Broadcastable(topic);
}
@Broadcast @POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Broadcastable publish(
@FormParam("message") String message) {
return new Broadcastable(message, topic);
}
}
1
5 48
49. Questions?
• Send feedback
• JSR 311
– dev@jsr311.dev.java.net
– http://jsr311.dev.java.net/
– Note: project will transition from CollabNet to Kenai
infrastructure at the end of the month
• Jersey
– users@jersey.java.net
– http://jersey.java.net/
1
6 49