1
Jun 20, 2015
1
<Insert Picture Here>
Future of Java EE
Jerome DochezGlassfish 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.
Java EE and… the Cloud?
• Containers are back in vogue!
4
Java EE and… the Cloud?
• We have containers...• We have services… injectable services…• We scale to large clusters…• We have a security model…
5
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
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
Cloud Platform
Application
Virtualization Layer
State Management
JavaService
PersistenceService
QueueingService
…
8
Cloud Platform
CodeModule
CodeModule
Schema Migration QoS InformationSecurity
CodeModule
…
Virtualization Layer
State Management
JavaService
PersistenceService
QueueingService
…
9
Application
Cloud Platform
Application Application Application
Virtualization Layer
State Management
JavaService
PersistenceService
QueueingService
…
10
Cloud Platform
Application Application Application Application Application
Virtualization Layer
State Management
JavaService
PersistenceService
QueueingService
…
11
Cloud Platform
Managed Environment
Application Application Application
Virtualization Layer
State Management
JavaService
PersistenceService
QueueingService
…
Application Application
12
Demo Application
Database
RESTClient
EJB/CDIJSF
JPA
JPA
EJB Timer
Jersey Client API
Browser
Modularity
• Build on Java SE work• Applications made of modules• Dependencies are explicit• Versioning is built-in• Classloaders straightened out
14
Modular Applications
15
demo.app
demo-web-1.0.3
Modular Applications
16
twitter-client-2.3.0
demo.app
demo-web-1.0.3
demo-persist-1.4.0
Modular Applications
javaee-web-7.0
twitter-client-2.4.0
jpa-2.1
demo.app
demo-web-1.0.3demo-persist-1.4.0
17
jax-rs-2.0
requires
requiresrequires
Modular Applications
javaee-web-7.0
twitter-client-2.3.0
jpa-2.1
demo.app
demo-web-1.0.3demo-persist-1.4.0
18
jax-rs-2.0
requires
requiresrequires
Modular Applications
javaee-web-7.0
twitter-client-2.3.0
jpa-2.1
…………
gf-appserver-4.0.1
demo.app
demo-web-1.0.3demo-persist-1.4.0
19
jax-rs-2.0
implements
requires
requires
Modular Applications
javaee-web-7.0
twitter-client-2.3.0
jpa-2.1
…………
gf-appserver-4.0.1eclipselink-2
demo.app
demo-web-1.0.3demo-persist-1.4.0
20
jersey-2.0
jax-rs-2.0
implements
implementsimplements
Modular Applications
javaee-web-7.0
twitter-client-2.4.0
jpa-2.1
…………
gf-appserver-4.0.1eclipselink-2
demo.app
demo-web-1.0.4demo-persist-1.4.0
21
jersey-2.1.1
jax-rs-2.1
Modular Applications
jersey-2.1.5
javaee-web-7.0
twitter-client-2.4.0
jax-rs-2.1jpa-2.1
…………
gf-appserver-4.1.5eclipselink-2
jersey-2.1.1
jax-rs-2.1demo.app
demo-web-1.0.4demo-persist-1.4.0
22
JSF 2.1: short term
• Transient State Saving• UIData Transient state saving• XML view cleanup• Facelets Cache API• “XML free” in specification
23
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
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
Web Tier
• Web socket support• Standard JSON API• HTML5 support• NIO.2-based web container
26
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
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
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
Java Persistence 2.1 Candidate FeaturesO/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
Java Persistence 2.1 Candidate FeaturesAPI 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
Java Persistence 2.1 Candidate FeaturesEnhancements 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
queries5
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
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
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
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
37
List<Future<?>>
• Hypermedia• Improved @Inject integration• Parameter validation
–Using Bean Validation API (JSR-303)
• Improve ease of use–DRY–Convention over configuration
4
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
39
Standard injection declarations
public class Foo { @Context UriInfo ui;
@Context public setRequest(Request r) { … }
public Foo(@QueryParam("x") int x) { … }}
6
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
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
42
Supported now with CDI
@RequestScopedpublic class Foo { @Inject UriInfo ui;
@Inject public setRequest(Request r) { … }
public Foo() {} @Inject public Foo(@QueryParam("x") int x) { … }
@Inject SomeOtherDependency o;}
9
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) { ... }}
10
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) { ... }
}
11
45
Annotate non-entity parameters?
public class Foo { @Inject SomeOtherDependency o;
@GET public String post( String s, @InjectParam UriInfo ui, @InjectParam SomeOtherDependency o) { ... }}
12
46
Annotate entity parameter?
public class Foo { @Inject SomeOtherDependency o;
@GET public String post( @Entity String s, UriInfo ui, SomeOtherDependency o) { ... }}
13
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
14
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); }}
15
49
Questions?
• Send feedback• JSR 311
–[email protected]–http://jsr311.dev.java.net/–Note: project will transition from CollabNet to Kenai
infrastructure at the end of the month
• Jersey–[email protected]–http://jersey.java.net/
16