Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Java EE 8 and the Open Future of Java EE - What You Need to Know!

118,032 views

Published on

Java EE 8 has been the most community opinion driven release in the history of the platform. Java EE 8 solidly enables HTTP/2, Server-Sent Events (SSE), JSON and aligning all parts of the platform with Java SE 8. It includes a much awaited security API overhaul as well as a slew of critical updates to APIs like JSF, JPA, JAX-RS and CDI.

While the road to Java EE 8 has not been smooth, the future of Java EE looks brighter than ever. Innovative efforts like MicroProfile aim to add features like dynamic configuration, health-checks, fat-jars, dynamic discovery and circuit breakers to Java EE. Most importantly Java EE is headed to a much more open future outside the walls of Oracle in the Eclipse Foundation.

This session will explain all of these promising developments including the details of what is in Java EE 8. We will also discuss the critical role Java EE and it's APIs play in maintaining the health of the entire Java ecosystem.

Published in: Technology

Java EE 8 and the Open Future of Java EE - What You Need to Know!

  1. 1. Others Talk, We Listen. Java EE 8 and Java EE 9 - What You Need to Know! Reza Rahman Senior Architect rrahman@captechconsulting.com @reza_rahman
  2. 2. CapTech Full-service US national IT consulting firm that focuses on client best interests, trust, servant leadership, culture, professionalism and technical excellence. #28 in Vault's Consulting Top 50 #3 Best Consulting Internship #9 Best Overall Internship #1 in Meeting Client’s Needs #7 Best Firm to Work For #1 in Career Development Ranked for the 7th Consecutive Year Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  3. 3. J2EE 1.3 CMP, JCA J2EE 1.4 Web Services, Mgmt, Deplymn t Java EE 5 Ease of Use, EJB 3, JPA, JSF, JAXB, JAX-WS Java EE 6 Pruning, Ease of Use, JAX-RS, CDI, Bean- Validation Web Profile Servlet 3, EJB 3.1 Lite Java EE 7 JMS 2, Batch, TX, Concurr, Web- Sockets, JSON Web Profile JAX-RS 2 J2EE 1.2 Servlet, JSP, EJB, JMS, RMI Java EE Past, Present and Future
  4. 4. The Continued Importance of Java EE Copyright © 2015 CapTech Ventures, Inc. All rights reserved. https://javaee-guardians.io/java-ee-adoption-surveys https://javaee-guardians.io/java-ee-adoption-stories
  5. 5. Java EE Ecosystem Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  6. 6. Microservices and Java EE Copyright © 2015 CapTech Ventures, Inc. All rights reserved. http://microprofile.io
  7. 7. Java EE 8 Community Survey Copyright © 2015 CapTech Ventures, Inc. All rights reserved. https://java.net/downloads/javaee-spec/JavaEE8_Community_Survey_Results.pdf
  8. 8. Java EE 8 Scope • Web Standards Alignment • HTTP/2, SSE, JSON-B, JSON-P, action-oriented web framework • CDI Alignment • CDI 2, EJB services outside EJB, EJB pruning, JSF managed bean pruning • Enterprise • Security, JCache, JMS • Java SE 8 Alignment • JSF, JPA, JAX-RS, Bean Validation Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  9. 9. Servlet 4 • Principal goal to support HTTP 2 • Request/response multiplexing over single connection • Multiple streams, stream prioritization • Server push • Binary framing • Header compression • Most of it can be done without major API changes Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  10. 10. • API to marshal/un-marshal POJOs to/from JSON • Very similar to JAXB in the XML world • Default mapping of classes to JSON • Annotations to customize default mappings • @JsonbProperty, @JsonbTransient • Provide JAX-RS a built-in way to support “application/json” for POJOs • JAX-RS currently supports JSON-P • Providers support non–standard binding APIs Copyright © 2015 CapTech Ventures, Inc. All rights reserved. JSON-B Java API for JSON Binding
  11. 11. JSON-B Example Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @Entity public class Person { @Id String name; String gender; @ElementCollection Map<String, String> phones; ... } Person duke = new Person(); duke.setName("Duke"); duke.setGender("Male"); phones = new HashMap<>(); phones.put("home", "650-123-4567"); phones.put("mobile", "650-234-5678"); duke.setPhones(phones); { "name":"Duke", "gender":"Male", "phones":{ "home":"650-123-4567", "mobile":"650-234-5678" } }
  12. 12. • Updates to JSON parsing API added in Java EE 7 • Adapt to new JSON standards • JSON Pointer • JSON Patch • Java SE 8 alignment Copyright © 2015 CapTech Ventures, Inc. All rights reserved. JSON-P 1.1
  13. 13. JSON-Pointer Example Copyright © 2015 CapTech Ventures, Inc. All rights reserved. JsonArray contacts = ...; JsonPointer pointer = new JsonPointer( "/0/phones/mobile"); JsonValue value = pointer.getValue(contacts); [ { "name":"Duke", "gender":"Male", "phones":{ "home":"650-123-4567", "mobile": "650-234-5678"}}, { "name":"Jane", "gender":"Female", "phones":{ "mobile": "707-555-9999"}} ]
  14. 14. • Modifying parts of a JSON document • Patch itself a JSON document • add, replace, remove, move, copy, test operations • Must have "op" field and "path" field, may have “value” field Copyright © 2015 CapTech Ventures, Inc. All rights reserved. JSON-Patch [ {"op": "replace", "path":"/0/phones/mobile", "value":"650-111-2222"}, {"op": "remove", "path":"/1"} ]
  15. 15. JSON-Patch Example Copyright © 2015 CapTech Ventures, Inc. All rights reserved. [ { "op":"replace", "path":"/0/phones/mobile", "value":"650-111-2222"}, { "op":"remove", "path":"/1"} ] [ { "name":"Duke", "gender":"Male", "phones":{ "home":"650-123-4567", "mobile":"650-234-5678"}}, { "name":"Jane", "gender":"Female", "phones":{ "mobile":"707-555-9999"}} ] JsonPatchBuilder builder = new JsonPatchBuilder(); JsonArray result = builder.replace("/0/phones/mobile", "650-111-2222") .remove("/1") .apply(target);
  16. 16. • Lesser known part of HTML 5 • Server-to-client streaming • “Stock tickers”, monitoring applications • Just plain long-lived HTTP • Between the extremes of vanilla request/response and WebSocket • Content-type ‘text/event-stream’ • Support via JAX-RS 2.1 • Non-standard API in Jersey Copyright © 2015 CapTech Ventures, Inc. All rights reserved. Server-Sent Events (SSE)
  17. 17. SSE on the Server-Side Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @Path("tickers") public class StockTicker { @Resource ManagedExecutorService executor; @GET @Produces("text/event-stream") public void getQuotes( @Context SseEventSink sink, @Context Sse sse) { executor.execute(() -> { ... sink.onNext(sse.newEvent(stockqoute)); ... sink.close(); ... }); } }
  18. 18. • Simplify security for Java EE and improve portability • Simple security providers • Database, LDAP • Simple pluggability • Universal security context • Enabling existing security annotations (@RolesAllowed) for all beans • EL enabled security annotations via interceptors • OAuth, OpenID, JWT Copyright © 2015 CapTech Ventures, Inc. All rights reserved. Java EE Security
  19. 19. Simple Security Providers Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @DataBaseIdentityStoreDefinition ( dataSourceLookup="java:global/MyDB", callerQuery= "SELECT password FROM principals WHERE username=?", groupsQuery="SELECT role FROM roles where username=?", ...) @LdapIdentityStoreDefinition ( url="ldap://ds.acme.com:389", baseDn="dc=acme,dc=com", ...)
  20. 20. Simple Security Pluggability Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @SecurityProvider public class MySecurityProvider { @Inject UserService userService; @OnAuthentication // The parameters should suit the credentials mechanism being // used. public Principal getPrincipal( String username, String password) { // Construct the principal using the user service. } @OnAuthorization public String[] getRoles (Principal principal) { // Construct an array of roles using the principal and user // service. } }
  21. 21. Security Context Example Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @AccessLogged @Interceptor public class AccessLoggingInterceptor { @Inject private SecurityContext security; @AroundInvoke public Object logMethodAccess(InvocationContext ctx) throws Exception { System.out.println("Entering method: " + ctx.getMethod().getName()); System.out.println("Current principal: " + security.getCallerPrincipal()); System.out.println("User is admin: " + security.isCallerInRole("admin")); return ctx.proceed(); } }
  22. 22. EL Enabled Security Annotations Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @IsAuthorized("hasRoles('Manager') && schedule.officeHours") public void transferFunds(); @IsAuthorized( "hasRoles('Manager') && hasAttribute('directReports', employeeId)") public double getSalary(long employeeId);
  23. 23. CDI 2 • Java SE bootstrap, modularity • Asynchronous events • Portable extension SPI simplifications and enhancements • Java SE 8 alignment Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  24. 24. Asynchronous CDI Events Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @Inject @CargoInspected Event<Cargo> cargoInspected; ... public void inspectCargo(TrackingId trackingId) { ... cargoInspected.fireAsync(cargo); } public void onCargoInspected( @ObservesAsync @CargoInspected Cargo cargo) {
  25. 25. JMS 2.1 • Declarative message listeners • Alternative to MDB, available to all beans • Simpler syntax • More powerful features • More portability • Redelivery delay, redelivery limits, dead message queues Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  26. 26. Declarative JMS Listeners Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @ApplicationScoped @MaxConcurrency(10) public class HandlingEventRegistrationAttemptConsumer { @JmsListener( destination="jms/HandlingEventRegistrationAttemptQueue", selector="source = 'mobile'", batchSize=10, retry=5, retryDelay=7000, deadLetterQueue=“jms/DLQ”, orderBy=TIMESTAMP) @Transactional public void onEventRegistrationAttempt( HandlingEventRegistrationAttempt... attempts) { ... } }
  27. 27. • Standard action-based web framework • JSF continues to evolve separately • Model • CDI, Bean Validation, JPA • View • Facelets, JSP • Controller • Majority of work here • Based on JAX-RS Copyright © 2015 CapTech Ventures, Inc. All rights reserved. MVC
  28. 28. MVC Example Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @Controller @Path("/") @View("my-index.xhtml") public class Bookstore { @Inject private Models model; @GET public void index() { model.put(”books", books); } }
  29. 29. Adopting Java SE 8 • Most of Java SE 8 can already be used with Java EE • Some APIs should adopt features • Repeatable Annotations • JPA, JMS, JavaMail, EJB • Date-Time API • JSF, JPA, Bean Validation • Completable Future • JAX-RS, EJB, WebSocket, Concurrency Utilities Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  30. 30. Repeatable Annotations in Java EE Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @NamedQueries({ @NamedQuery(name=SELECT_ALL, query="..."), @NamedQuery(name=COUNT_ALL, query="...") }) public class Customer { ... @NamedQuery(name=SELECT_ALL, query="...") @NamedQuery(name=COUNT_ALL, query="...") public class Customer { ...
  31. 31. Date/Time API with JPA Copyright © 2015 CapTech Ventures, Inc. All rights reserved. @Entity public class Accident { @Temporal(TemporalType.TIMESTAMP) @Past private Instant when; }
  32. 32. CompletableFuture with JAX-RS Copyright © 2015 CapTech Ventures, Inc. All rights reserved. CompletionStage<String> cs1 = client.target("http://partner.us/api") .request() .rx() .get(String.class); CompletionStage<String> cs2 = client.target("http://supplier.be/api") .request() .rx() .get(String.class); // Get both responses in a List (when they are available) CompletionStage<List<String>> listCompletionStage = cs1.thenCombine(cs2, Arrays::asList);
  33. 33. Some Other Changes • JSF/WebSocket integration • JSF/CDI integration • More Bean Validation constraints • @Email, @NotEmpty • Broadcasting SSE events • CDI event ordering Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  34. 34. Java EE Guardians http://javaee-guardians.io @javaee_guardian Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  35. 35. Oracle Java EE 8/9 Survey Copyright © 2015 CapTech Ventures, Inc. All rights reserved. https://blogs.oracle.com/theaquarium/entry/java_ee_8_community_survey2
  36. 36. Java EE 8 Scope • Web Standards Alignment • HTTP/2, SSE, JSON-B, JSON-P, action-oriented web framework • CDI Alignment • CDI 2, EJB services outside EJB, EJB pruning, JSF managed bean pruning • Enterprise • Security, JCache, JMS • Java SE 8 Alignment • JSF, JPA, JAX-RS, Bean Validation Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  37. 37. Java EE 8/9 Roadmap Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  38. 38. Java EE 9 • OAuth, OpenID, JWT • Dynamic configuration • Fat jars, modularity • Health check/metrics • Circuit breakers • Dynamic discovery • Client-side load-balancing • NoSQL • Multitenancy • Events • State management • Eventual consistency Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  39. 39. Summary • Java EE remains vitally important to all of us • Java EE 8 has long-awaited critical features • There have been serious concerns, but Oracle has now committed to Java EE 8 and Java EE 9 • Java EE 9 ideas are preliminary, concrete work already being done in MicroProfile • The time to get involved is now! Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
  40. 40. Copyright©2015CapTechVentures,Inc.Allrightsreserved.

×