Java EE - The Road Ahead - David Delabassee, Oracle

1,056
-1

Published on

Oracle Java Developer Day 28.11.2012

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,056
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Java EE - The Road Ahead - David Delabassee, Oracle

  1. 1. Java EE - The Road AheadOracle Java Developer DayWarszawa Nov. 2012David Delabassee - @delabasseeJava EE & GlassFish Team Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  2. 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.2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  3. 3. Java EE Past & Present Productivity & HTML5 Java EE 7 Lightweight JMS 2.0, Ease of Batch, Java EE 6 Caching, TX Development Interceptor, Java EE 5 Pruning, WebSocket, Web Extensibility JSON, Services Ease of Dev, Concurrency J2EE 1.4 CDI, JAX-RS JAX-RPC, CMP/ Enterprise Robustness Ease of BMP, JSR 88Java Platform J2EE 1.3 Web Services Development, Mgmt, Annotations, Web Profile Web Profile J2EE 1.2 Deployment, EJB 3.0, JPA, Async JSF, JAXB, Servlet 3.0, JAX-RS 2.0 Servlet, JSP, CMP, JAX-WS, Connector EJB 3.1 Lite EJB, JMS, Connector StAX, SAAJ RMI/IIOP ArchitectureDec 1999 Sep 2001 Nov 2003 May 2006 Dec 2009 Q2 201310 specs 13 specs 20 specs 23 specs 28 specs 32+ specs 3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  4. 4. Java EE Past, Present, & Future Productivity & HTML5 Java EE 7 Lightweight JMS 2.0, Ease of Batch, Java EE 6 Caching, TX Development Interceptor, Java EE 5 Pruning, WebSocket, Web Extensibility JSON, Services Ease of Dev, Concurrency J2EE 1.4 CDI, JAX-RS JAX-RPC, CMP/ Enterprise Robustness Ease of BMP, JSR 88Java Platform J2EE 1.3 Web Services Development, Mgmt, Annotations, Web Profile Web Profile J2EE 1.2 Deployment, EJB 3.0, JPA, Async JSF, JAXB, Servlet 3.0, JAX-RS 2.0 Servlet, JSP, CMP, JAX-WS, Connector EJB 3.1 Lite EJB, JMS, Connector StAX, SAAJ RMI/IIOP ArchitectureDec 1999 Sep 2001 Nov 2003 May 2006 Dec 2009 Q2 201310 specs 13 specs 20 specs 23 specs 28 specs 32+ specs 4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  5. 5. Java EE 7 - Revised Scope Productivity and HTML5 • Higher Productivity – Less Boilerplate – Richer Functionality – More Defaults • HTML5 Support – WebSocket – JSON – HTML5 Forms • JSR 3525 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  6. 6. Java EE 7 - Candidate JSRs JAX-RS JSP 2.2 JSF 2.2 EL 3.0 Java Caching API Portable 2.0Extensions Bean Validation 1.1 Servlet 3.1 Batch Applications Common Interceptors 1.1 CDI 1.1 Java API for JSONAnnotations 1.1 Java API for Managed Beans 1.0 EJB 3.2 WebSocketConnector JPA 2.1 JTA 1.2 JMS 2.0 Concurrency 1.6 New Major Updated Release 6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  7. 7. Java EE 7 - New APIs7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  8. 8. Java API for JSON Processing 1.0 JSR 353 • API to parse, generate, transform, query, ... JSON • Streaming API – Similar to StAX • Object Model API – Similar to DOM • Binding JSON to Java objects forthcoming8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  9. 9. Java API for JSON Processing 1.0 Build a JSON object JsonObject jsonObject = new JsonBuilder()"phoneNumber": [ .beginArray("phoneNumber") { .beginObject() "type": "home", .add("type", "home") "number": ”321-123-4567” .add("number", "321-123-4567") }, .endObject() { .beginObject() "type": ”work", .add("type", ”work") "number": ”123-456-7890” .add("number", "123-456-7890") } .endObject() ] .endArray() .build();9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  10. 10. WebSocket • Bi-directional full-duplex communication protocol – IETF RFC 6455 – TCP based – Handshake to establish connection – Send message back & forth – End the connection • Extensible – Eg. multiplexing • Part of HTML 5 – W3C JavaScript API10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  11. 11. Java API for WebSocket 1.0 JSR 356 • API for events, messaging, sessions – Client & Server APIs • Session • Endpoint & Remote Endpoint • Message Handler – Handles all incoming messages for an Endpoint11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  12. 12. Java API for WebSocket 1.0 HelloWorld - Server import javax.net.websocket.*; public class HelloServer extends Endpoint { @Override public void onOpen(Session session) { session.addMessageHandler(new MessageHandler.Text() { public void onMessage(String text) { System.out.println(“Someone said “ + text); } }); } }12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  13. 13. Java API for WebSocket 1.0 HelloWorld - Client import javax.net.websocket.*; public class HelloClient extends Endpoint { @Override public void onOpen(Session session) { try { session.getRemote().sendString("Hello world"); } catch (IOException ioe) { // Oops! } } }13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  14. 14. Java API for WebSocket 1.0 Hello Annotation import javax.net.websocket.annotations.*; @WebSocketEndpoint(“/hello”) public class HelloBean { @WebSocketMessage public void handleMessage(String message) { System.out.println(“Someone said: “ + message); } }14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  15. 15. Batch Applications for the Java Platform 1.0 JSR 35215 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  16. 16. Java Temporary Caching API 1.0 JSR 107 • API for temporary in-memory caching of Java objects • “Interceptor” to protect (expensive) resources • Improve capacity / performance • Scaling out • Java SE 6, Java EE 6 (and above)16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  17. 17. Concurrency and Java EE • Component code is run on a thread managed by a container • Container expects all access to container-supplied objects to occur on the same thread • Unable to reliably use Java EE services from a un- managed thread • Don’t use Java SE Concurrency APIs17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  18. 18. Concurrency Utilities for Java EE JSR 236 • Easily add concurrency to Java EE applications • Consistent between the Java SE and EE platforms • Simple to advanced concurrency patterns without sacrificing usability • Tasks – Units of work that represent a computation or some business logic – Implementations of java.util.concurrent.Callable and java.lang.Runnable interfaces18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  19. 19. WebSocket Demo19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  20. 20. Java EE 7 - Revised APIs20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  21. 21. Java API for RESTful Web Services 2.0 JSR 339 • Message Filters & Entity Interceptors • Asynchronous Processing – Server & Client • Hypermedia Support • Common Configuration • Client API21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  22. 22. Java API for RESTful Web Services ClientString address = String.format ("http://…/orders/%0$s/customer?shipped=%1$b", "7", true);URL url = new URL(address);HttpURLConnection conn = (HttpURLConnection) url.openConnection();conn.setRequestMethod("GET");conn.setDoInput(true);conn.setDoOutput(false);BufferedReader br = new BufferedReader( new InputStreamReader(conn.getInputStream()));String line;while ((line = br.readLine()) != null) { //...}22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  23. 23. Java API for RESTful Web Services 2.0 Client API // Get instance of Client Client client = ClientFactory.newClient(); // Get customer name for the shipped products String name = client.target(“../orders/{orderId}/customer”) .pathParam(”orderId", ”7”) .queryParam(”shipped", ”true”) .request() .get(String.class);23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  24. 24. Java Message Service Primer • A standard messaging API – Application API only • Not a messaging system in itself – Not a wire protocol • Java API only – Doesn’t define API for non-Java clients • Widely used but... • JMS 1.1 – Circa 200224 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  25. 25. Java Message Service Sending a Message using JMS 1.1 @Resource(lookup = "myConnectionFactory”) ConnectionFactory connectionFactory; @Resource(lookup = "myQueue”) Queue myQueue; public void sendMessage (String payload) { Connection connection = null; try { connection = connectionFactory.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer messageProducer = session.createProducer(myQueue); TextMessage textMessage = session.createTextMessage(payload); messageProducer.send(textMessage); } catch (JMSException ex) { //. . . } finally { if (connection != null) { try { connection.close(); } catch (JMSException ex) { //. . . } } }25 } Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  26. 26. Java Message Service 2.0 JSR 343 • Define new simplified API – + Simplify existing API • Reduce boilerplate code • Less verbose • Resource injection • Connection, Session and other objects are Auto- Closable • Requires Resource Adapter for Java EE containers26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  27. 27. Java Message Service 2.0 Simplify the existing API • New methods to create session • Existing methods remains – connection.createSesssion(transacted, deliveryMode) • New method for Java SE – connection.createSesssion(sessionMode) • New method for Java EE – connection.createSesssion()27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  28. 28. Java Message Service 2.0 Simplify the existing API @Resource(lookup = "jms/connFactory") ConnectionFactory cf; Existing @Resource(lookup="jms/inboundQueue") Destination dest; connection.createSession(transacted, deliveryMode); public void sendMessage (String payload) throws JMSException { try ( Connon conn = connectionFactory.createConnection(); Session session = conn.createSession(); New28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  29. 29. Java Message Service 2.0 Simplify the existing API @Resource(lookup = "jms/connFactory") ConnectionFactory cf; @Resource(lookup="jms/inboundQueue") Destination dest; public void sendMessage (String payload) throws JMSException { try ( Connection conn = connectionFactory.createConnection(); Session session = conn.createSession(); try with MessageProducer producer = session.createProducer(dest); resource ){ Message mess = sess.createTextMessage(payload); producer.send(mess); } catch(JMSException e){ // exception handling } }29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  30. 30. Java Message Service 2.0 Sending a Message using JMS 2.0 Simplified API Default resource definition @Inject Or JMSContext context; @JmsConnectionFactory @Resource(mappedName=”myQueue") Queue myQueue; 18 lines 1 line public void sendMessage(String payload) { context.createProducer().send(myQueue, payload); }30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  31. 31. Many other improvements ... • JavaServer Faces 2.2 : HTML 5, Face Flows, ... • JPA 2.1: Schema generation, unsynchronized PC, ... • EJB 3.2: Optional CMP/BMP, Ease-of-use, Refactoring, … • Servlet 3.1: Non-blocking IO, Upgrade to WebSocket, … • EL 3.0: Lambda expressions, Collection, Operators, … • JTA 1.2: Transactional interceptors • CDI 1.1: Ordering of interceptors, Servlet events, … • Beans Validation 1.1 : Method Parameter and Result Validation, ...31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  32. 32. Wrap up...32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  33. 33. Java EE 7 - Candidate JSRs JAX-RS JSP 2.2 JSF 2.2 EL 3.0 Java Caching API Portable 2.0Extensions Bean Validation 1.1 Servlet 3.1 Batch Applications Common Interceptors 1.1 CDI 1.1 Java API for JSONAnnotations 1.1 Java API for Managed Beans 1.0 EJB 3.2 WebSocketConnector JPA 2.1 JTA 1.2 JMS 2.0 Concurrency 1.6 New Major Updated Release33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  34. 34. Java EE 7 – Implementation Status 4.0 http://download.java.net/glassfish/4.0/promoted/34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  35. 35. Java EE 8 and Beyond Standards-based cloud programming model • Deliver cloud architecture Storage NoSQL • Multi tenancy for SaaS JSON-B Multitenancy Java EE 7 applications Concurrency Cloud • Modularity based on Jigsaw PaaS Enablement Thin Server Architecture • Incremental delivery of JSRs35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  36. 36. Advanced Tooling for HTML 5 Introducing Project Easel • Provides the foundation for tooling support for Project Avatar • Consume Java EE based services with today’s popular JavaScript frameworks36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  37. 37. Internet of Things 31 billion devices, 4 billion people connected by 202037 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  38. 38. Java Embedded Suite38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  39. 39. Call To Action • Java EE 7 Transparent Expert Groups – http://javaee-spec.java.net • GlassFish – http://glassfish.org – http://blogs.oracle.com/theaquarium • NetBeans – https://netbeans.org • Java Embedded Suite – http://oracle.com/us/technologies/java/embedded/suite/39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  40. 40. Graphic Section Divider40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

×