Java ee 7 New Features

3,745 views

Published on

Java EE 7 New Features discussed in pakijug session in Karachi, Pakistan.

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

No Downloads
Views
Total views
3,745
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
97
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Java ee 7 New Features

  1. 1. Java EE 7 – New Features? Presenter: Shahzad Badar
  2. 2. Agenda  Who am I?  Java EE 7 – New Features? Pakistan Java User Group
  3. 3. Who am I? A programmer working on java since 2002 Spent most of the time in Islamabad Leading Pakistan Java User Group Working in Royal Cyber Pakistan Java User Group
  4. 4. Catch me @shahzadbadar shahzadbadar@gmail.com http://www.implementsjava.com Pakistan Java User Group
  5. 5. Pakistan Java User Group
  6. 6. Pakistan Java User Group
  7. 7. Java EE 6 - Achievements  50,000,000 + downloads  #1 choice for enterprise developers  #1 application development platform  Fastest adoptions of any Java EE release – 18 complaint servers Pakistan Java User Group
  8. 8. Java EE 6 – Main Features  Web Profile  EJB packaged in war  Optional web.xml  Type-safe dependency injection  CDI Events  JSF standardizing on facelets  @Schedule Pakistan Java User Group
  9. 9. JEE 7 Theme Pakistan Java User Group
  10. 10. Pakistan Java User Group
  11. 11. Active JSRs  JSR 342: Java EE 7 Platform  JSR 338: Java API for RESTful Web Services 2.0  JSR 339: Java Persistence API 2.1  JSR 340: Servlet 3.1  JSR 341: Expression Language 3.0  JSR 343: Java Message Service 2.0  JSR 344: JavaServer Faces 2.2  JSR 345: Enteprise JavaBeans 3.2  JSR 346: Contexts and Dependency Injection 1.1  JSR 349: Bean Validation 1.1  JSR 236: Concurrency Utilities for Java EE 1.0  JSR 352: Batch Applications for the Java Platform 1.0  JSR 353: Java API for JSON Processing 1.0  JSR 356: Java API for WebSocket 1.0 Pakistan Java User Group
  12. 12. Concurrency and Java EE  Managing your own threads within a Java EE container is not recommended  Using java.util.concurrent API in a Java EE application component such as EJB or Servlet are problematic since the container and server have no knowledge of these resource  Provides simple, safe API for concurrency in Java EE  Builds on Java SE concurrency java.util.concurrent.ExecutorService Pakistan Java User Group
  13. 13. Pakistan Java User Group
  14. 14. Batch Applications for the Java Platform  Batch processing is execution of series of "jobs" that is suitable for non-interactive, bulk-oriented and long-running tasks.  no standard Java programming model existed for batch applications. Pakistan Java User Group
  15. 15. Pakistan Java User Group
  16. 16. Java EE Web Profile Enhancements  The Java Enterprise Edition Web Profile was introduced in Java EE 6  Most Web applications have significant requirements in the areas of transaction management, security, and persistence.  but are not supported by standalone servlet containers  Web Profile is provided with pre-installed, pre- integrated, fully tested Web infrastructure features.  The Java EE 7 Web Profile adds support for HTML5 with WebSockets, JSON, JAX-RS 2.0, and more. Pakistan Java User Group
  17. 17. Bean Validation 1.1  Method constraints  Bean Validation artifacts injectable  Fixes, clarifications and enhancements Pakistan Java User Group
  18. 18. Bean Validation 1.1 Method Level Constraints Pakistan Java User Group public void placeOrder( @NotNull String productName, @NotNull @Max(“10”) Integer quantity, @Customer String customer) { . . . } @Future public Date getAppointment() { . . . }
  19. 19. JSF 2.2  HTML5 Support  @FlowScoped  @ViewScoped for CDI  Managed beans deprecated/CDI alignment  File upload component  View actions  Multi-templating  Security  Fixes and enhancements Pakistan Java User Group
  20. 20. JSON Processing Support  JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write.  It is easy for machines to parse and generate.  It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999.  JSON is a text format that is completely language independent but uses conventions that are familiar to programmers Pakistan Java User Group { “employee": [ { "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" } ] } JSON Example
  21. 21. JSON Implementations for Java  org.json.  org.json.me.  Jackson JSON Processor.  Json-lib.  JSON Tools.  Stringtree.  SOJO.  Jettison.  json-taglib.  XStream.  Flexjson.  JON tools.  Argo.  jsonij.  fastjson.  mjson.  jjson.  json-simple.  json-io.  JsonMarshaller.  google-gson.  Json-smart.  FOSS Nova JSON.  Corn CONVERTER. Pakistan Java User Group a lot of implementations for other languages
  22. 22. Why we need another API? Pakistan Java User Group • JSON has become a defacto data transfer standard specially for RESTful Web Services. • Java applications use different implementations to consume and process JSON data • There should be standardized Java API for JSON so that applications do not need to bundle the implementation libraries
  23. 23. JSON Processing Support  API to parse and generate JSON  Streaming API  Low level efficient way to parse/generate JSON  Provide pluggability for parser/generator  Object Model  Simple, Easy-to-use high-level API  Implemented on top of Streaming API Pakistan Java User Group
  24. 24. Java API for JSON Processing Writing JSON (Object Model API) Pakistan Java User Group “employees": [ { “firstName": “Asif", “lastName": ”Naveed” }, { “firstName": “Khalid", “lastName": ”Ali” } ] JsonObject jsonObject = new JsonBuilder() .beginArray(“employees") .beginObject() .add(“firstName", “Asif") .add(“lastName", “Naveed") .endObject() .beginObject () .add(“firstName", “Khalid") .add(“lastName", “Ali").endObject() .endArray() .build();
  25. 25. Java API for JSON Processing Pakistan Java User Group { "firstName": "Javaid", "lastName": “Shah", "age": 19, "phoneNumber": [ { "type": “cell", "number": “03218983449" }, { "type": "fax", "number": “02142423212" } ] } Iterator<Event> it = parser.iterator(); Event event = it.next(); // START_OBJECT event = it.next(); // KEY_NAME event = it.next(); // VALUE_STRING String name = parser.getString(); // "Javaid” Reading JSON (Streaming API)
  26. 26. Web Socket Support In age of Web 2.0 / 3.0 , We need interactive websites Pakistan Java User Group but In the standard HTTP model, a server cannot initiate a connection with a client nor send an unrequested HTTP response to a client; thus, the server cannot push asynchronous events to clients.
  27. 27. Why WebSocket?  HTTP is half duplex  HTTP is verbose  Hacks for Server Push  Polling  Long Polling  Comet/Ajax  Complex, Wasteful, Inefficient Pakistan Java User Group
  28. 28. HTTP Communication Pakistan Java User Group
  29. 29. Polling Pakistan Java User Group
  30. 30. Long Polling Pakistan Java User Group
  31. 31. HTTP Streaming (Comet) Pakistan Java User Group
  32. 32. WebSocket to rescue  TCP based, bi-directional, full-duplex messaging  Capable of sending both UTF-8 string and binary frames in any direction at the same time  Operating from a single socket across the web  As part of HTML5, the application of the client interface will become native to all modern browsers  To establish a Web Socket connection, the browser or client simply makes a request to the server for an upgrade from HTTP to a Web Socket Pakistan Java User Group
  33. 33. WebSocket to rescue Pakistan Java User Group
  34. 34. Pakistan Java User Group “Reducing kilobytes of data to 2 bytes…and reducing latency from 150ms to 50ms is far more than marginal. In fact, these two factors alone are enough to make Web Sockets seriously interesting to Google.”
  35. 35. Java WebSocket Implementations Pakistan Java User Group
  36. 36. WebSocket API Connection Life Cycle @Singleton @WebSocketEndpoint(path=”/chat”) public class ChatServer { Set<Session> peers = ... @WebSocketOpen public void onOpen(Session peer) { peers.add(session); } @WebSocketClose public void onClose(Session session) { peers.remove(session); } ... Pakistan Java User Group
  37. 37. WebSocket API WebSocket Communication . . . @WebSocketMessage public void message(String message, Session client) throws IOException { for (Session session : peers) { if (!session.equals(client)) { session.getRemote().sendObject(message); } } } } Pakistan Java User Group
  38. 38. JPA 2.1 – New Features The first spec to include new features is the JPA 2.1. The new features can be described with the following short list:  Multi-Tenancy (Table discriminator)  Stored Procedures  Custom types and transformation methods - Query by Example  Dynamic PU Definition  Schema Generation (Additional mapping metadata to provide better standardization) Pakistan Java User Group
  39. 39. Servlet 3.1 – New Features NIO.2 async I/O Leverage Java EE concurrency Security improvements Web Sockets support Ease-of-Development Pakistan Java User Group
  40. 40. Enteprise JavaBeans 3.2 – New Features The scope of EJB 3.2 is intended to be relatively constrained in focusing on these goals.  Incremental factorization (Interceptors)  Further use of annotations to simplify the EJB programming model  Proposed Optional: BMP/CMP  Proposed Optional: Web Services invocation using RPC Pakistan Java User Group
  41. 41. Java EE 8 Plan  JSON-B  JCache  More CDI/EJB alignment  Cloud, PaaS, multitenancy/SaaS  JMS.next()?  JAX-RS.next()?  Modularity?  NoSQL?  Action-oriented Web framework/HTML 5?  Configuration API?  Security? Pakistan Java User Group
  42. 42. References  http://www.oracle.com/technetwork/java/javaee/index. html  https://blogs.oracle.com/arungupta/  http://www.infoq.com/presentations/Java-EE-7-8 Pakistan Java User Group
  43. 43. Pakistan Java User Group

×