0
The Java EE 7 Platform:Productivity and HTML5Arun Gupta (@arungupta)Java EE & GlassFish Guy  1   Copyright © 2012, Oracle ...
The following is intended to outline our general product    direction. It is intended for information purposes only, and  ...
Java EE 6 Platform                                                                           December 10, 20093   Copyrigh...
Java EE 6 – Key Statistics    •  40+ Million Java EE 6 Component Downloads    •  #1 Choice for Enterprise Developers    • ...
Top Ten Features in Java EE 6    1.  EJB packaging in a WAR    2.  Type-safe dependency injection    3.  Optional deployme...
Java EE 7 Revised Scope    Productivity and HTML5    •  Higher Productivity             –  Less Boilerplate             – ...
Java EE 7 – Candidate JSRs                                                                                 JAX-RS         ...
Java API for RESTful Web Services 2.0       •  Client API       •  Message Filters & Entity Interceptors       •  Asynchro...
Java API for RESTful Web Services 2.0    Client API - Before      String address = String.format("http://…/orders/%0$s/cus...
Java API for RESTful Web Services 2.0     Client API - Now      // Get instance of Client      Client client = ClientFacto...
Java API for RESTful Web Services 2.0     Filters @Provider
 class LoggingFilter implements ContainerRequestFilter {!     ...
Java API for RESTful Web Services 2.0         Client-side AsyncClient client = ClientFactory.newClient();
Future<String> f...
Java Message Service 2.0     Simplify the existing API     •  Less verbose     •  Reduce boilerplate code     •  Resource ...
Java Message Service 2.0     Sending message using JMS 1.1           @Resource(lookup = "java:global/jms/demoConnectionFac...
Java Message Service 2.0     Sending message using JMS 1.1                                                      must creat...
Java Message Service 2.0     Sending message using JMS 1.1                                                                ...
Java Message Service 2.0     Sending message using JMS 1.1           @Resource(lookup = "java:global/jms/demoConnectionFac...
Java Message Service 2.0     Sending message using JMS 1.1           @Resource(lookup = "java:global/jms/demoConnectionFac...
Java Message Service 2.0     Sending message using JMS 1.1           @Resource(lookup = "java:global/jms/demoConnectionFac...
Java Message Service 2.0     Sending message using JMS 1.1           @Resource(lookup = "java:global/jms/demoConnectionFac...
Java Message Service 2.0     Simpler API to close JMS objects                                                             ...
Java Message Service 2.0                                                            JMSContext     Introducing JMSContext ...
Java Message Service 2.0     Default resource definition                                                                  ...
Java API for JSON Processing 1.0     •  API to parse and generate JSON     •  Streaming API             –  Low-level, effi...
Java API for JSON Processing 1.0     Streaming API – JsonParser and JsonGenerator     •  JsonParser           –  Parses JS...
Java API for JSON Processing 1.0     Streaming API – JsonParser and JsonGenerator     •  JsonGenerator           –  Genera...
Java API for JSON Processing 1.0     Streaming API – JsonGenerator
                                                       ...
Java API for JSON Processing 1.0     Object Model API     •  JsonObject/JsonArray – JSON object and array        structure...
Java API for JSON Processing 1.0     DOM API – JsonReader     •  Reads JsonObject and JsonArray from input source         ...
Java API for WebSocket 1.0     •  Create WebSocket Client/Endpoints           –  Annotation-driven (@WebSocketEndpoint)   ...
Java API for WebSocket 1.0     Hello World – POJO/Annotation-drivenimport javax.net.websocket.annotations.*;

@WebSocketEn...
Java API for WebSocket 1.0     WebSocket Annotations                            Annotation                                ...
Java API for WebSocket 1.0     @WebSocketEndpoint Attributes                                                              ...
Bean Validation 1.1     •  Open: Spec, Reference Implementation, TCK     •  Alignment with Dependency Injection     •  Met...
Bean Validation 1.1     Method Parameter and Result Validation                                                            ...
Batch Applications for the Java Platform 1.0     •  Suited for non-interactive, bulk-oriented and long-running        task...
Batch Applications for the Java Platform 1.0     Concepts     •  Job: Entire batch process             –  Put together thr...
Batch Applications for the Java Platform 1.0     Job Specification Language – Simple Job     <job id=“myJob”>
       <step...
Batch Applications for the Java Platform 1.0       Job Specification Language – Chunked Step<step id=”sendStatements”>!   ...
Java Temporary Caching API 1.0     •  API and semantics for temporary, in-memory caching of        Java objects     •  SPI...
Java Temporary Caching API 1.0     •  javax.cache.*!     •  Delivered as part of Java EE 7           –  Immediately usable...
Java Temporary Caching API 1.0     Key Concepts     •  Cache Manager =>Caches     •  Cache => Entries     •  Entry => Key,...
Java Temporary Caching API 1.0     Code Sample – Blog     public class BlogManager { !               @CachePut(cacheName=”...
Java Temporary Caching API 1.0     Code Sample – Blog               . . .
     
               @CacheResult(cacheName="blo...
Java Temporary Caching API 1.0     Annotations – Blog Sample               . . .
     
               @CacheRemoveEntry(ca...
Java Persistence API 2.1     •  Schema Generation     •  Unsynchronized Persistence Contexts     •  Converters     •  Bulk...
Java Persistence API 2.1     Schema Generation     •  What: Generation of database artifacts           –  Tables, indexes,...
Java Persistence API 2.1     Schema Generation Properties     •  javax.persistence.schema-generation-action!           –  ...
Java Persistence API 2.1     Schema Generation Example from ORM Metadata     // mapped to EMPLOYEE table in default schema...
Enterprise JavaBeans 3.2     EJBs Today     •  @Singleton!     •  @Asynchronous!     •  @Schedule!     •  Portable JNDI Na...
Enteprise JavaBeans 3.2         Updates: Opt-in Transactions in SFSB Lifecycle Callbacks     @Stateful
     public class H...
Enterprise JavaBeans 3.2     Updates: Opt-out passivation of Stateful Session Beans       @Stateful(passivationCapable=fal...
Enterprise JavaBeans 3.2     Updates: Simplified Rules for Local/Remote Client Views     @Stateless
     public class Bean...
Enterprise JavaBeans 3.2     Updates: Simplified Rules for Local/Remote Client Views     @Remote
     public interface Foo...
Servlet 3.1     •  Non-blocking I/O     •  Protocol Upgrade     •  Security Enhancements55   Copyright © 2012, Oracle and/...
Servlet 3.1     Non-blocking IO - Traditional     public class TestServlet extends HttpServlet
        protected void doGe...
Servlet 3.1     Non-blocking I/O: doGet Code Sample     AsyncContext context = request.startAsync();
     ServletInputStre...
Servlet 3.1     Non-blocking I/O: MyReadListener Code Sample     @Override
     public void onDataAvailable() {
        tr...
Servlet 3.1     Non-blocking I/O: MyListener Code Sample     . . .
     @Override
     public void onAllDataRead() {
     ...
Concurrency Utilities for Java EE 1.0     Goals     •  Provide concurrency capabilities to Java EE application        comp...
Concurrency Utilities for Java EE 1.0     ManagedExecutorService     •  Manageable version of        java.util.concurrent....
Concurrency Utilities for Java EE 1.0     Defining ManagedExecutorService using JNDI     •  Recommended to bind in java:co...
Concurrency Utilities for Java EE 1.0     Submit Tasks to ManagedExecutorService using JNDI     public class TestServlet e...
Concurrency Utilities for Java EE 1.0     ManagedThreadFactory     •  Provides a method for creating threads for execution...
Concurrency Utilities for Java EE 1.0     ManagedThreadFactory Sample     @Resource(“concurrent/LoggerThreadFactory”)
    ...
Java Transaction API 1.2     •  Declarative transactions outside EJB           –  Based on CDI interceptors     •  Add ann...
Java Transaction API 1.2     public @interface Transactional {
        TxType value() default TxType.REQUIRED
     }!     ...
Java Transaction API 1.2     public class ShoppingCart {!                ...!                @Transactional
              ...
JavaServer Faces 2.2     •  HTML5 Friendly Markup Support           –  Pass through attributes and elements     •  Faces F...
Contexts & Dependency Injection 1.1     •  Embedded mode to startup outside Java EE container     •  Global ordering of in...
Java EE 7 – Implementation Status                                                                            4.0          ...
Java EE 8 and Beyond     Standards-based cloud programming model     •  Deliver cloud architecture                        ...
Call to Action     •  Java EE 7 Expert Group             –  javaee-spec.java.net     •  Java EE 7 Reference Implementation...
Transparency     •  Oracle’s Java EE 7 JSRs are run in the open on java.net           –  http://javaee-spec.java.net      ...
Status and Schedule•  All JSRs up and running•  All Early Drafts, several Public Drafts•  Final release target: Q2 2013  7...
GlassFish RoadmapGlassFish v3                                                                        GlassFish Server 3.1 ...
Graphic Section Divider77   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Upcoming SlideShare
Loading in...5
×

The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012

5,712

Published on

The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012

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

No Downloads
Views
Total Views
5,712
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
126
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Transcript of "The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012"

  1. 1. The Java EE 7 Platform:Productivity and HTML5Arun Gupta (@arungupta)Java EE & GlassFish Guy 1 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 6 Platform December 10, 20093 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  4. 4. Java EE 6 – Key Statistics •  40+ Million Java EE 6 Component Downloads •  #1 Choice for Enterprise Developers •  #1 Application Development Platform •  Fastest implementation of a Java EE release4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  5. 5. Top Ten Features in Java EE 6 1.  EJB packaging in a WAR 2.  Type-safe dependency injection 3.  Optional deployment descriptors (web.xml, faces-config.xml) 4.  JSF standardizing on Facelets 5.  One class per EJB 6.  Servlet and CDI extension points 7.  CDI Events 8.  EJBContainer API 9.  Cron-based @Schedule! 10. Web Profile5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  6. 6. Java EE 7 Revised Scope Productivity and HTML5 •  Higher Productivity –  Less Boilerplate –  Richer Functionality –  More Defaults •  HTML5 Support –  WebSocket –  JSON –  HTML5 Forms6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  7. 7. Java EE 7 – Candidate JSRs JAX-RS Java Caching API JSP 2.2 JSF 2.2 2.0 EL 3.0 (JSR 107) PortableExtensions Bean Validation 1.1 Concurrency Utilities Servlet 3.1 (JSR 236) Common Batch Applications Interceptors 1.1 CDI 1.1 (JSR 352)Annotations 1.1 Java API for JSON Managed Beans 1.0 EJB 3.2 (JSR 353)Connector Java API for WebSocket JPA 2.1 JTA 1.2 JMS 2.0 (JSR 356) 1.6 New Major Updated Release 7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  8. 8. Java API for RESTful Web Services 2.0 •  Client API •  Message Filters & Entity Interceptors •  Asynchronous Processing – Server & Client •  Hypermedia Support •  Common Configuration8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  9. 9. Java API for RESTful Web Services 2.0 Client API - Before String address = String.format("http://…/orders/%0$s/customer?shipped= %1$b", "10", 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) {! //. . .! }!9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  10. 10. Java API for RESTful Web Services 2.0 Client API - Now // Get instance of Client Client client = ClientFactory.newClient();
 
 // Get customer name for the shipped products String name = client.target(“../orders/{orderId}/customer”)
 .resolveTemplate(”orderId", ”10”)
 .queryParam(”shipped", ”true”)
 .request()
 .get(String.class);!10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  11. 11. Java API for RESTful Web Services 2.0 Filters @Provider
 class LoggingFilter implements ContainerRequestFilter {!     @Override
     public void filter(ContainerRequestContext context) {
         logRequest(ctx.getRequest());
 // non-wrapping => returns without invoking next filter
     }
 }!11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  12. 12. Java API for RESTful Web Services 2.0 Client-side AsyncClient client = ClientFactory.newClient();
Future<String> future = client.target("http://.../atm/{card}/balance")
                              .pathParam("card", "1111222233334444")
                              .queryParam("pin", "1234")
                              .request("text/plain")
                              .async()
                              .get(
 new InvocationCallback<String>() {
 public void completed(String result) {
 }

 public void failed(InvocationException e) {
 }
 }
 );! 12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  13. 13. Java Message Service 2.0 Simplify the existing API •  Less verbose •  Reduce boilerplate code •  Resource injection •  Connection, Session, and other objects are AutoCloseable •  Requires Resource Adapter for Java EE containers •  Simplified API in both Java SE and EE13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  14. 14. Java Message Service 2.0 Sending message using JMS 1.1 @Resource(lookup = "java:global/jms/demoConnectionFactory")! ConnectionFactory connectionFactory;! ! @Resource(lookup = "java:global/jms/demoQueue")! Queue demoQueue;! ! public void sendMessage(String payload) {! try {! Connection connection = connectionFactory.createConnection();! try {! Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);! MessageProducer messageProducer = session.createProducer(demoQueue);! TextMessage textMessage = session.createTextMessage(payload);! 13 lines of messageProducer.send(textMessage);# } finally {! code just connection.close();! to send a }! } catch (JMSException ex) {! message Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);! }! } !14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  15. 15. Java Message Service 2.0 Sending message using JMS 1.1 must create several intermediate objects @Resource(lookup = "java:global/jms/demoConnectionFactory")! ConnectionFactory connectionFactory;! ! @Resource(lookup = "java:global/jms/demoQueue")! Queue demoQueue;! ! public void sendMessage(String payload) {! try {! Connection connection = connectionFactory.createConnection();! try {! Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);! MessageProducer messageProducer = session.createProducer(demoQueue);! TextMessage textMessage = session.createTextMessage(payload);! messageProducer.send(textMessage);! } finally {! connection.close();! }! } catch (JMSException ex) {! Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);! }! } !15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  16. 16. Java Message Service 2.0 Sending message using JMS 1.1 redundant and @Resource(lookup = "java:global/jms/demoConnectionFactory")! ConnectionFactory connectionFactory;! misleading ! arguments @Resource(lookup = "java:global/jms/demoQueue")! Queue demoQueue;! ! public void sendMessage(String payload) {! try {! Connection connection = connectionFactory.createConnection();! try {! Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);! MessageProducer messageProducer = session.createProducer(demoQueue);! TextMessage textMessage = session.createTextMessage(payload);! messageProducer.send(textMessage);! } finally {! connection.close();! }! } catch (JMSException ex) {! Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);! }! } !16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  17. 17. Java Message Service 2.0 Sending message using JMS 1.1 @Resource(lookup = "java:global/jms/demoConnectionFactory")! ConnectionFactory connectionFactory;! boilerplate ! @Resource(lookup = "java:global/jms/demoQueue")! code Queue demoQueue;! ! public void sendMessage(String payload) {! try {! Connection connection = connectionFactory.createConnection();# try {! Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);# MessageProducer messageProducer = session.createProducer(demoQueue);# TextMessage textMessage = session.createTextMessage(payload);! messageProducer.send(textMessage);! } finally {! connection.close();! }! } catch (JMSException ex) {! Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);! }! } !17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  18. 18. Java Message Service 2.0 Sending message using JMS 1.1 @Resource(lookup = "java:global/jms/demoConnectionFactory")! ConnectionFactory connectionFactory;! ! @Resource(lookup = "java:global/jms/demoQueue")! Queue demoQueue;! ! public void sendMessage(String payload) {! try {! Connection connection = connectionFactory.createConnection();! try {# Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);! MessageProducer messageProducer = session.createProducer(demoQueue);! TextMessage textMessage = session.createTextMessage(payload);! messageProducer.send(textMessage);! } finally {# must close connection.close();# }# resources } catch (JMSException ex) {! after use! Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);! }! } !18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  19. 19. Java Message Service 2.0 Sending message using JMS 1.1 @Resource(lookup = "java:global/jms/demoConnectionFactory")! ConnectionFactory connectionFactory;! ! @Resource(lookup = "java:global/jms/demoQueue")! Queue demoQueue;! ! public void sendMessage(String payload) {! try {! Connection connection = connectionFactory.createConnection();! try {! Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);! MessageProducer messageProducer = session.createProducer(demoQueue);! TextMessage textMessage = session.createTextMessage(payload);! messageProducer.send(textMessage);! all methods } finally {! throw checked connection.close();! }! exceptions } catch (JMSException ex) {! Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);! }! } !19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  20. 20. Java Message Service 2.0 Sending message using JMS 1.1 @Resource(lookup = "java:global/jms/demoConnectionFactory")# ConnectionFactory connectionFactory;# pre-create app- # server specific @Resource(lookup = "java:global/jms/demoQueue")# resources Queue demoQueue;# ! public void sendMessage(String payload) {! try {! Connection connection = connectionFactory.createConnection();! try {! Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);! MessageProducer messageProducer = session.createProducer(demoQueue);! TextMessage textMessage = session.createTextMessage(payload);! messageProducer.send(textMessage);! } finally {! connection.close();! }! } catch (JMSException ex) {! Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);! }! } !20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  21. 21. Java Message Service 2.0 Simpler API to close JMS objects Create closeable resources in a try- @Resource(lookup = "jms/connFactory")
 with-resources block ConnectionFactory cf; ! @Resource(lookup="jms/inboundQueue")! Destination dest;! ! public void sendMessage (String payload) throws JMSException {! try ( Connection conn = connectionFactory.createConnection(); # Session session = conn.createSession();# MessageProducer producer = session.createProducer(dest);# ){ ! Message mess = sess.createTextMessage(payload); ! close() is called producer.send(mess); ! automatically } catch(JMSException e){ ! at end of block // exception handling ! }
 }!21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  22. 22. Java Message Service 2.0 JMSContext Introducing JMSContext and JMSProducer combines Connection and Session @Resource(lookup = "java:global/jms/demoConnectionFactory")! ConnectionFactory connectionFactory; ! ! Payload @Resource(lookup = "java:global/jms/demoQueue")! can be sent Queue demoQueue;! directly ! public void sendMessage (String payload) {! try (JMSContext context = connectionFactory.createContext();){! context.createProducer().send(demoQueue, payload);# } catch (JMSRuntimeException ex) {! // exception handling! }! close() is called }! automatically No checked at end of block exceptions thrown22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  23. 23. Java Message Service 2.0 Default resource definition Default resource definition Or @JmsConnectionFactory# @Inject
 JMSContext context;! ! @Resource(lookup = "java:global/jms/demoQueue”)
 Queue demoQueue;! ! public void sendMessage(String payload) {! context.createProducer().send(demoQueue, payload);! }! 13 lines è1 line#23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  24. 24. Java API for JSON Processing 1.0 •  API to parse and generate JSON •  Streaming API –  Low-level, efficient way to parse/generate JSON –  Provides pluggability for parsers/generators •  Object Model –  Simple, easy-to-use high-level API –  Implemented on top of Streaming API •  Binding JSON to Java objects forthcoming24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  25. 25. Java API for JSON Processing 1.0 Streaming API – JsonParser and JsonGenerator •  JsonParser –  Parses JSON in a streaming way from input sources •  Similar to StaX’s XMLStreamReader, a pull parser –  Created using •  Json.createParser(…)! •  Json.createParserFactory().createParser(…)! –  Parser state events •  START_ARRAY, END_ARRAY, START_OBJECT, END_OBJECT, ...25 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  26. 26. Java API for JSON Processing 1.0 Streaming API – JsonParser and JsonGenerator •  JsonGenerator –  Generates JSON in a streaming way to output sources •  Similar to StaX’s XMLStreamWriter –  Created using •  Json.createGenerator(…)! •  Json.createGeneratorFactory().createGenerator(…)! –  Optionally, configured with features •  E.g. for pretty printing26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  27. 27. Java API for JSON Processing 1.0 Streaming API – JsonGenerator
 JsonGenerator jg = Json.createGenerator(…);
"phoneNumber": [! 
 { 
 jg.
 "type": "home", 
 .beginArray("phoneNumber")
 "number": ”408-123-4567”
 .beginObject() 
 },! .add("type", "home") 
 {
 .add("number", "408-123-4567") 
 "type": ”work", 
 .endObject() 
 "number": ”408-987-6543”
 .beginObject() 
 }! .add("type", ”work") 
 ]! .add("number", "408-987-6543") 
 .endObject() 
 .endArray();
 jg.close(); !27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  28. 28. Java API for JSON Processing 1.0 Object Model API •  JsonObject/JsonArray – JSON object and array structures –  JsonString and JsonNumber for string and number values •  JsonBuilder – Builds JsonObject and JsonArray •  JsonReader – Reads JsonObject and JsonArray from input source •  JsonWriter – Writes JsonObject and JsonArray to output source28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  29. 29. Java API for JSON Processing 1.0 DOM API – JsonReader •  Reads JsonObject and JsonArray from input source –  i/o Reader, InputStream (+ encoding) •  Optionally, configured with features •  Uses pluggable JsonParser! // Reads a JSON object try(JsonReader reader = new JsonReader(io)) {! JsonObject obj = reader.readObject();! }! !29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  30. 30. Java API for WebSocket 1.0 •  Create WebSocket Client/Endpoints –  Annotation-driven (@WebSocketEndpoint) –  Interface-driven (Endpoint) •  Integration with Java EE Web container30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  31. 31. Java API for WebSocket 1.0 Hello World – POJO/Annotation-drivenimport javax.net.websocket.annotations.*;

@WebSocketEndpoint("/hello")
public class HelloBean {

 @WebSocketMessage
 public String sayHello(String name) {
 return “Hello “ + name;
 }
}!31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  32. 32. Java API for WebSocket 1.0 WebSocket Annotations Annotation Level Purpose @WebSocketEndpoint! class Turns a POJO into a WebSocket Endpoint @WebSocketOpen! method Intercepts WebSocket Open events @WebSocketClose! method Intercepts WebSocket Close events @WebSocketMessage! method Intercepts WebSocket Message events method @WebSocketPathParam! Flags a matched path segment of a URI-template parameter @WebSocketError! method Intercepts errors during a conversation32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  33. 33. Java API for WebSocket 1.0 @WebSocketEndpoint Attributes Relative URI or URI template value! e.g. /hello or /chat/{subscriber-level} decoders! list of message decoder classnames encoders! list of message encoder classnames subprotocols! list of the names of the supported subprotocols33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  34. 34. Bean Validation 1.1 •  Open: Spec, Reference Implementation, TCK •  Alignment with Dependency Injection •  Method-level validation –  Constraints on parameters and return values –  Check pre-/post-conditions34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  35. 35. Bean Validation 1.1 Method Parameter and Result Validation Need more slides here public void placeOrder( 
 @NotNull String productName,
Built-in @NotNull @Max(“10”) Integer quantity,
Custom @Customer String customer) { 
 //. . .
 }! @Future
 public Date getAppointment() {
 //. . .
 }!35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  36. 36. Batch Applications for the Java Platform 1.0 •  Suited for non-interactive, bulk-oriented and long-running tasks •  Computationally intensive •  Can execute sequentially/parallel •  May be initiated –  Adhoc –  Scheduled •  No scheduling APIs included36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  37. 37. Batch Applications for the Java Platform 1.0 Concepts •  Job: Entire batch process –  Put together through a Job Specification Language (XML) •  Step: Independent, sequential phase of a job –  ItemReader: Retrieval of input for a step, one at a time –  ItemProcessor: Business processing of an item –  ItemWriter: Output of an item, chunks of items at a time •  JobOperator: Manage batch processing •  JobRepository: Metadata for jobs37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  38. 38. Batch Applications for the Java Platform 1.0 Job Specification Language – Simple Job <job id=“myJob”>
 <step id=“init”>
 <chunk reader=“R” writer=W” processor=“P” />
 <next on=“initialized” to=“process”/>
 <fail on=“initError”/>
 </step>
 <step id=“process”>
 <batchlet ref=“ProcessAndEmail”/>
 <end on=”success”/>
 <fail on=”*” exit-status=“FAILURE”/>
 </step>
 </job> !38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  39. 39. Batch Applications for the Java Platform 1.0 Job Specification Language – Chunked Step<step id=”sendStatements”>! @ReadItem
 <chunk reader=”AccountReader”! public Account readAccount() {
 processor=”AccountProcessor”
 // read account using JPA! writer=”EmailWriter”! }! chunk-size=”10” />! !</step>! @ProcessItem# public Account processAccount(Account account) {
 // calculate balance! }! @WriteItems# ! public void sendEmail(List<Account> accounts) {
 // use JavaMail to send email! }! ! 39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  40. 40. Java Temporary Caching API 1.0 •  API and semantics for temporary, in-memory caching of Java objects •  SPI for implementers •  Designed to support “local” and “distributed” caching •  Caching strategies supported –  By value (default) –  By reference (not suitable for “distributed” caching)40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  41. 41. Java Temporary Caching API 1.0 •  javax.cache.*! •  Delivered as part of Java EE 7 –  Immediately usable by Java EE 6, Spring and Guice –  Immediately usable by any Java app •  Not a Data Grid specification –  JSR 107 does not mandate a topology –  JSR 347 does: builds on JSR 10741 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  42. 42. Java Temporary Caching API 1.0 Key Concepts •  Cache Manager =>Caches •  Cache => Entries •  Entry => Key,Value •  CacheManager acquired via CacheManagerFactory! •  CacheManagerFactory acquired via Service Provider –  META-INF/services/javax.cache.spi.CachingProvider!42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  43. 43. Java Temporary Caching API 1.0 Code Sample – Blog public class BlogManager { ! @CachePut(cacheName=”blogManager”)
 public void createEntry(
 @CacheKeyParam String title,
 @CacheValue Blog blog) {...}
 
 . . .!43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  44. 44. Java Temporary Caching API 1.0 Code Sample – Blog . . .
 
 @CacheResult(cacheName="blogManager") 
 public Blog getBlogEntry(String title) {...} ! 
 @CacheResult(cacheName="blogManager") 
 public Blog getEntryCached(
 String randomArg, 
 @CacheKeyParam String title) {...}
 
 . . .!44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  45. 45. Java Temporary Caching API 1.0 Annotations – Blog Sample . . .
 
 @CacheRemoveEntry(cacheName="blogManager") 
 public void removeBlogEntry(String title) {...} 
 ! @CacheRemoveAll(cacheName="blogManager") 
 public void removeAllBlogs() {...}! } !45 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  46. 46. Java Persistence API 2.1 •  Schema Generation •  Unsynchronized Persistence Contexts •  Converters •  Bulk update/delete using Criteria! •  User-defined functions using FUNCTION •  Stored Procedure Query46 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  47. 47. Java Persistence API 2.1 Schema Generation •  What: Generation of database artifacts –  Tables, indexes, constraints, generators, … •  Scenarios: Iterative prototyping, production, database provisioning (e.g. in cloud) •  To: Database, DDL, Both •  From: O/R mapping metadata, SQL DDL scripts •  When: Prior to app deployment47 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  48. 48. Java Persistence API 2.1 Schema Generation Properties •  javax.persistence.schema-generation-action! –  “none”, “create”, “drop-and-create”, “drop” •  javax.persistence.schema-generation-target! –  “database”, “scripts”, “database-and-scripts” •  javax.persistence.ddl-create-script-target/source! •  javax.persistence.ddl-drop-script-target/source! •  javax.persistence.sql-load-script-source! •  . . .!48 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  49. 49. Java Persistence API 2.1 Schema Generation Example from ORM Metadata // mapped to EMPLOYEE table in default schema @Entity public class Employee {# @Id private int id; // mapped to ID column as primary key private String name; // mapped to NAME column, VARCHAR(255) ...# @ManyToOne // mapped to DEPT_ID foreign key column private Department dept;# ...# }#49 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  50. 50. Enterprise JavaBeans 3.2 EJBs Today •  @Singleton! •  @Asynchronous! •  @Schedule! •  Portable JNDI Name •  EJBContainer.createEJBContainer! •  EJB 3.1 Lite50 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  51. 51. Enteprise JavaBeans 3.2 Updates: Opt-in Transactions in SFSB Lifecycle Callbacks @Stateful
 public class HelloBean {
 
 @PersistenceContext(type=PersistenceContextType.EXTENDED)
 private EntityManager em;! ! @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)# @PostConstruct# public void init() { . . . }! 
 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
 @PreDestroy# public void destroy () { . . . }!51 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  52. 52. Enterprise JavaBeans 3.2 Updates: Opt-out passivation of Stateful Session Beans @Stateful(passivationCapable=false)# public class HelloBean {! private NonSerializableType ref = …;! ! …! }!52 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  53. 53. Enterprise JavaBeans 3.2 Updates: Simplified Rules for Local/Remote Client Views @Stateless
 public class Bean implements Foo, Bar {
 }! Local @Local @Stateless
 public class Bean implements Foo, Bar {
 }! Remote @Remote @Stateless
 public class Bean implements Foo, Bar {
 }!53 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  54. 54. Enterprise JavaBeans 3.2 Updates: Simplified Rules for Local/Remote Client Views @Remote
 public interface Foo { . . . }
 
 public interface Bar { . . . ]
 
 Remote @Stateless
 public class Bean implements Foo, Bar {
 }!54 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  55. 55. Servlet 3.1 •  Non-blocking I/O •  Protocol Upgrade •  Security Enhancements55 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  56. 56. Servlet 3.1 Non-blocking IO - Traditional public class TestServlet extends HttpServlet
 protected void doGet(HttpServletRequest request,
 HttpServletResponse response) 
 throws IOException, ServletException {
 ServletInputStream input = request.getInputStream();
 byte[] b = new byte[1024];
 int len = -1;
 while ((len = input.read(b)) != -1) {
 . . .
 }
 }
 }!56 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  57. 57. Servlet 3.1 Non-blocking I/O: doGet Code Sample AsyncContext context = request.startAsync();
 ServletInputStream input = request.getInputStream();
 input.setReadListener(
 new MyReadListener(input, context)); !57 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  58. 58. Servlet 3.1 Non-blocking I/O: MyReadListener Code Sample @Override
 public void onDataAvailable() {
 try {
 StringBuilder sb = new StringBuilder();
 int len = -1;
 byte b[] = new byte[1024];
 while (input.isReady() && (len = input.read(b)) != -1) {
 String data = new String(b, 0, len);
 System.out.println("--> " + data);
 }
 } catch (IOException ex) {
 . . .
 }
 }
 . . .
58 ! Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  59. 59. Servlet 3.1 Non-blocking I/O: MyListener Code Sample . . .
 @Override
 public void onAllDataRead() {
 context.complete();
 }
 
 @Override
 public void onError(Throwable t) {
 t.printStackTrace();
 context.complete();
 } !59 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  60. 60. Concurrency Utilities for Java EE 1.0 Goals •  Provide concurrency capabilities to Java EE application components –  Without compromising container integrity •  Support simple (common) and advanced concurrency patterns •  Provide consistency between Java SE and Java EE concurrency programming model –  Extend the Concurrency Utilities API (JSR 166)60 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  61. 61. Concurrency Utilities for Java EE 1.0 ManagedExecutorService •  Manageable version of java.util.concurrent.ExecutorService –  Lookup using JNDI •  Java EE components create task classes –  Implement java.lang.Runnable or java.util.concurrent.Callable! •  Submitted using submit or invoke methods •  Multiple (configurable) executors are permitted61 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  62. 62. Concurrency Utilities for Java EE 1.0 Defining ManagedExecutorService using JNDI •  Recommended to bind in java:comp/env/concurrent subcontext <resource-env-ref>
 <resource-env-ref-name>
 concurrent/BatchExecutor
 </resource-env-ref-name>
 <resource-env-ref-type>
 javax.enterprise.concurrent.ManagedExecutorService
 </resource-env-ref-type>
 </resource-env-ref>!62 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  63. 63. Concurrency Utilities for Java EE 1.0 Submit Tasks to ManagedExecutorService using JNDI public class TestServlet extends HTTPServlet {
 @Resource(name=“concurrent/BatchExecutor”)
 ManagedExecutorService executor;
 
 Future future = executor.submit(new MyTask());
 
 class MyTask implements Runnable {
 public void run() { 
 . . . // task logic
 }
 }
 }
63 ! Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  64. 64. Concurrency Utilities for Java EE 1.0 ManagedThreadFactory •  Provides a method for creating threads for execution in a managed environment •  Lookup using JNDI <resource-env-ref>
 <resource-env-ref-name>
 concurrent/LoggerThreadFactory
 </resource-env-ref-name>
 <resource-env-ref-type>
 javax.enterprise.concurrent.ManagedThreadFactory
 </resource-env-ref-type>
 </resource-env-ref>!64 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  65. 65. Concurrency Utilities for Java EE 1.0 ManagedThreadFactory Sample @Resource(“concurrent/LoggerThreadFactory”)
 ManagedThreadFactory threadFactory;# 
 LoggerTask task = new LoggerTask();
 Thread thread = threadFactory.newThread(task);
 
 LoggerTask implements Runnable {
 public void run() { . . . }
 }!65 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  66. 66. Java Transaction API 1.2 •  Declarative transactions outside EJB –  Based on CDI interceptors •  Add annotation and standard values to javax.transaction package66 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  67. 67. Java Transaction API 1.2 public @interface Transactional {
 TxType value() default TxType.REQUIRED
 }! public enum TxType {
 REQUIRED,
 REQUIRED_NEW,
 MANDATORY,
 SUPPORTS,
 NOT_SUPPORTED,
 NEVER
 }! !67 ! Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  68. 68. Java Transaction API 1.2 public class ShoppingCart {! ...! @Transactional
 public void checkOut() {...}! ...! }!68 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  69. 69. JavaServer Faces 2.2 •  HTML5 Friendly Markup Support –  Pass through attributes and elements •  Faces Flows •  Cross Site Request Forgery Protection •  Loading Facelets via ResourceHandler! •  File Upload Component •  Multi-templating69 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  70. 70. Contexts & Dependency Injection 1.1 •  Embedded mode to startup outside Java EE container •  Global ordering of interceptors and decorators •  API for managing built-in contexts •  Send Servlet events as CDI events •  . . .70 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  71. 71. Java EE 7 – Implementation Status 4.0 download.java.net/glassfish/4.0/promoted/71 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  72. 72. 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 PaaS •  Incremental delivery of JSRs Enablement Thin Server Architecture •  Modularity based on Jigsaw72 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  73. 73. Call to Action •  Java EE 7 Expert Group –  javaee-spec.java.net •  Java EE 7 Reference Implementation –  glassfish.org •  The Aquarium –  blogs.oracle.com/theaquarium •  Adopt-a-JSR –  glassfish.org/adoptajsr73 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  74. 74. Transparency •  Oracle’s Java EE 7 JSRs are run in the open on java.net –  http://javaee-spec.java.net –  One project per spec – e.g., jpa-spec, jax-rs-spec, jms-spec… •  Publicly viewable Expert Group mail archive –  Users observer list gets copies of all Expert Group emails •  Publicly viewable download area •  Publicly viewable issue tracker •  Commitment to update to JCP 2.8 Process74 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  75. 75. Status and Schedule•  All JSRs up and running•  All Early Drafts, several Public Drafts•  Final release target: Q2 2013 75 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  76. 76. GlassFish RoadmapGlassFish v3 GlassFish Server 3.1 GlassFish Server 3.1.2•  Java EE 6 support •  Centralized administration •  Bug Fixes•  Single instance •  Clustering / HA •  Incremental features•  GlassFish Enterprise Mgr •  GlassFish Server Control 2009 2010 2011 2012 2013 GlassFish Server 3.0.1 GlassFish Server 3.1.1 GlassFish Server 4 •  Oracle branding •  Bug fixes •  Java EE 7 •  Oracle platform support •  Updated components •  Multitenancy •  Oracle interoperability •  Incremental features •  PaaS-enablement 76 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  77. 77. Graphic Section Divider77 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×