63
JAVA EE 8 UPDATE Ryan Cuprak

Java EE 8 Update

Embed Size (px)

Citation preview

Page 1: Java EE 8 Update

JAVA EE 8 UPDATERyan Cuprak

Page 2: Java EE 8 Update

Agenda• Java EE 8 specification overview and current status• Example of proposed enhancements• JavaOne 2016 Java EE Reboot• How to get involved and help

Page 3: Java EE 8 Update

Importance of Java EE

https://javaee-guardians.io/java-ee-adoption-surveys

Page 4: Java EE 8 Update

Java EE Ecosystem

Page 5: Java EE 8 Update

Microservices and Java EE

http://microprofile.io

Page 6: Java EE 8 Update

Java EE: Past, Present, Future

J2EE 1.2Servlet,

JSP, EJB, JMS, RMI

J2EE 1.3

CMP,JCA

J2EE 1.4

Web Services,

Mgmt, Deploy

Java EE 5Ease of

Use,EJB 3,

JPA, JSF, JAXB,

JAX-WS

Java EE 6

Pruning,Ease of

Use,JAX-RS,

CDI,Bean-

ValidationWeb Profile

Servlet 3,EJB 3.1 Lite

Java EE 7

JMS 2, Batch, TX,

Concurrency

Web-Sockets,

JSON

Java EE 8

SERVLET 4, JSON-B,

JSON-P 1.1, JSF 2.3, CDI 2.0, JAX-

RS 2.1,SECURITY

Page 7: Java EE 8 Update

Java EE 8 Community Survey

https://java.net/downloads/javaee-spec/JavaEE8_Community_Survey_Results.pdfhttps://blogs.oracle.com/ldemichiel/entry/results_from_the_java_ee

Page 8: Java EE 8 Update

Java EE 8 Overview – Original Plan• Continued Enhancements for Web Standards Alignment

• HTTP/2, JSON Binding, JSON-P, MVC• Cloud enhancements

• Security, RESTful Management API• CDI Programming Model

• Ease of use, EJB via CDI• Smaller, but Important Features

• Caching, Better Messaging• Alignment with Java SE 8

Page 9: Java EE 8 Update

Java EE 8 Specifications (Original)• JMS 2.1• JAX-RS 2.1• JSF 2.3• CDI 2.0• JSON-P 1.1• Servlet 4.0

• JCache 1.0• JSON-B 1.0• MVC 1.0• Java EE Security1.0• Java EE Management 2.0

Page 10: Java EE 8 Update

Java EE 8 RebootJSRs proposed to be dropped:• Management 2.0 (JSR 373)• JMS 2.1 (JSR 368)• MVC 1.0 (JSR 371)Expanded scope:• Security 1.0 (JSR 375)Proposed new JSRs:• Health Checking• Configuration

New Survey Conducted Results Not Yet Published

New Target Release Q4 2017

Page 11: Java EE 8 Update

UPDATED SPECIFICATION

Page 12: Java EE 8 Update

Servlet 4.0• Early Draft published 10/2015• Early implementation available in Tomcat 9

JSR 369

Expert Group Activity

Page 13: Java EE 8 Update

Servlet 4.0: HTTP/2• HTTP/2 Support -> Major Update• Why do we need HTTP/2?

• Problems with HTTP/1.1:• Head-of-Line Blocking• HTTP Pipelining, File Concatenation, & Image Sprites

• Key differences:• Binary instead of textual• Fully multiplexed instead of ordered and blocking• One connection for parallelism• Uses header compression• Allows server push

JSR 369

Page 14: Java EE 8 Update

Servlet 4.0: HTTP/2 Support

NOTE: HTTPS only for browsers!

Page 15: Java EE 8 Update

Servlet 4.0• Principal goal to support HTTP/2• Request/response multiplexing over single connection• Transparent to most developers, although possibly slight

changes to the Servlet API• Most affected: frameworks

JSR 369

Page 16: Java EE 8 Update

Servlet 4.0 – Exposing HTTP./2• Stream Prioritization

• New Priority class• Enhance HttpServletRequest and HttpServletResponse to

accommodate• Server Push

• Frameworks can push resources to the client• Not replacing WebSockets

JSR 369

Page 17: Java EE 8 Update

Servlet 4.0 - HttpClient API• Plans to provide easy to use API• Target HttpClient in Java 9• Support both HTTP/1.1 and 2• Builds on existing Java API Classes

JSR 368

Page 18: Java EE 8 Update

JMS 2.1 Asynchronous BatchesExample:@MessageDrivenpublic class MyFlexibleMDB {  @JMSQueueListener(destinationLookup="java:global/ myQueue")  public void myMessageCallback(@Batch(maxSize=10,timeout= 1000) Message[] messages) {    ...  }

JSR 368

Page 19: Java EE 8 Update

JMS 2.1 Declarative JMS Listeners@ApplicationScoped@MaxConcurrency(10)public class HandlingEventRegistrationAttemptConsumer { @JmsListener( destinationLookup="jms/HandlingEventRegistrationAttemptQueue", selector="source = 'mobile'", batchSize=10, retry=5, retryDelay=7000, orderBy=TIMESTAMP) @Transactional public void onEventRegistrationAttempt( HandlingEventRegistrationAttempt... attempts) {

... }}

JSR 368

Page 20: Java EE 8 Update

JAX-RS 2.1• JSR 370 - In Early Stages• No builds available for testing.• Reboot: Add Circuit Breaker support

JSR 370

Expert Group Activity

Page 21: Java EE 8 Update

JAX-RS 2.1• Hypermedia API• Reactive API• Security API• Support for SSE (Server Sent Events) • Improved CDI Integration• Support for Non-Blocking IO in Providers

JSR 370

Page 22: Java EE 8 Update

JAX-RS 2.1• Conditional JAXB on Runtimes• Integration with JSON-B• Support for CDI in Java SE

JSR 370

Page 23: Java EE 8 Update

JSF 2.3• JSR 372 - in active progress• Milestones available for testing• Read, Test, Supply Feedback

JSR 372

Emails from Oracle spec leads

Page 24: Java EE 8 Update

JSF 2.3• Standardize Web Socket integration

• f:websocket• Multi-field validation• Enhanced CDI Integration• Lifecycle Enhancements

• PostRenderViewEvent• EL API Enhancements• Configuration Enhancements• AJAX Enhancements

JSR 372

Page 25: Java EE 8 Update

JSF 2.3 Enhanced CDI IntegrationInjection of Resources

@Inject FacesContext facesContext;

@ApplicationMap@InjectMap applicationMap;

JSR 372

Page 26: Java EE 8 Update

JSF 2.3 Enhanced CDI Integration• Wider Support of Injection into JSF Artifacts

• javax.faces.convert.Converter• javax.faces.validator.Validator• javax.faces.component.behavior.Behavior

• Upgraded to CDI qualifiers

JSR 372

Page 27: Java EE 8 Update

CDI 2.0• JSR 365 - in active progress• Early draft review 2 published August 2016• Test Releases of Reference Implementation http

://weld.cdi-spec.org/news/

JSR 374

Page 28: Java EE 8 Update

CDI 2.0• Java SE Bootstrap• XML Configuration• Asynchronous Events• @Startup for CDI Beans• Portable Extension SPI Simplification• Small features and enhancements

JSR 374

Page 29: Java EE 8 Update

CDI 2.0Workshop Status DescriptionParts API was split Working on modularity (sub specs)

Events Finished Enhance events (asynchronous, ordering,etc… )

AOP Started Interceptors & Decoractors enhancement

Java SE First part done Boostrap CDI in Java SE

JDK 8 Started Enhancements from Java 8

SPI Not Started more open SPI for 3rd party

Contexts Not Started Provide a way to start/stop contexts for SE mode

JSR 374

Page 30: Java EE 8 Update

CDI Event System Enhancements• Asynchronous Events@Inject private ExperimentalEvent<Configuration> event; … event.fireAsync(new Configuration());

• Call to event.fireAsync() returns immediately

JSR 365

Page 31: Java EE 8 Update

CDI 2.0 @Schedule Outside EJB@ApplicationScopedpublic class MyScheduledBean { ... @Schedule(...) public void myScheduledTask() { ... }}@ApplicationScoped@Stereotype@Retention(RUNTIME)@Target(TYPE)@Schedule(...)public @interface MonthlyTask {}

JSR 365

Page 32: Java EE 8 Update

JSON-P 1.1• JSR 374 - In Early Draft Review• More Information:

• https://json-processing-spec.java.net/• Sources: https://java.net/projects/jsonp

JSR 374

Page 33: Java EE 8 Update

JSON-P 1.1• Updates to new API in Java EE 7

• New JSON Standards• JSON-Pointer and JSON-Patch• Editing Operations on JSON objects and arrays• Helper Classes and Enhanced Java SE 8 support

JSR 374

Page 34: Java EE 8 Update

JSON-P 1.1 Java SE 8 Support• Java 8 Stream Support• JsonArray persons; persons.getValuesAs(JsonObject.class).stream() .filter(x->x.getString(“age”) >= 65) .forEach(System.out.println(x.getString(“name”)));

JSR 374

Page 35: Java EE 8 Update

JSON-P 1.1: JSON-Pointer

JSR 374

Page 36: Java EE 8 Update

JSON-P 1.1: JSON-Patchpublic void shouldBuildJsonPatchExpressionUsingJsonPatchBuilder() { JsonPatchBuilder patchBuilder = new JsonPatchBuilder(); JsonObject result = patchBuilder.add("/email", "[email protected]") .replace("/age", 30) .remove("/phoneNumber") .test("/firstName", "John") .copy("/address/lastName", "/lastName") .apply(buildPerson());}

JSR 374

Page 37: Java EE 8 Update

Java EE Management API 2.0• Oracle proposing to drop JSR from EE 8.• Currently working on Early Draft• Java EE Management API 1.0 – released 2002• Join mailing list of JSR 373

JSR 373

Page 38: Java EE 8 Update

Java EE Management API 2.0• REST Based Interface to Supersede EJB Management

APIs of JSR 77• Monitoring and deployment• SSE for Event Support (WebSockets also under

consideration)

JSR 373

Page 39: Java EE 8 Update

Bean Validation 2.0• Add support for LocalTime, Optional, etc.• Leverage type annotation, repeatable annotations,

reflective parameter name retrieval• Potential enhancements:

• Customized constraint validations• Object graph validation

• Example:List<@Email String> emails;

JSR 380

Page 40: Java EE 8 Update

NEW SPECIFICATIONS

Page 41: Java EE 8 Update

MVC• Model - View - Controller• JSR 371• Active Progress…download milestones• Ozark: https://ozark.java.net/

JSR 371

Page 42: Java EE 8 Update

MVC• Action-Based Web Framework for Java EE

• Follows suit of Spring MVC or Apache Struts• Does Not Replace JSF• Model: CDI, Bean Validation, JPA• View: Facelets, JSP (Extensible) • Controller: Layered on top of JAX-RS

JSR 371

Page 43: Java EE 8 Update

MVC: Controller Example@Controller@Path("/customers")@View("my-view.jsp")public class CustomerController { @Inject private Models models; @GET public String getItems(){ . . . return “customers.jsp”;}

JSR 371

Page 44: Java EE 8 Update

MVC: View Example <c:forEach var="customer" items="${customers}"> <tr> <td class="text-left">${customer.name}</td> <td class="text-center"> <form action="${pageContext.request.contextPath}/r/customers/edit" method="POST"> <input type="hidden" name="id" value="${item.id}"/> <button type="submit"> Edit </button> </form> </td> </tr></c:forEach>

JSR 371

Page 45: Java EE 8 Update

JSON-B• Java API for JSON Binding• JSR 367 - Public Review• Read the spec, start testing: https://java.net/projects/jsonb-spec/pages/Home

JSR 367

Page 46: Java EE 8 Update

JSON-B Next Logical Step• Standardize means of converting JSON to Java objects

and vice versa• Default mapping algorithm for converting Java classes• Draw from best of breed ideas in existing JSON binding

solutions• Provide JAX-RS a standard way to support

“application/json” for POJOs• JAX-RS currently supports JSON-P

JSR 367

Page 47: Java EE 8 Update

JSON-B Mapping@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"

}}

JSR 367

Page 48: Java EE 8 Update

JSON-B: Proposed Custom Mapping• Utilization of annotations to map fields to JSON Document Elements

@JsonProperty(“poolType”)public String poolType;

@JsonPropertyOrder(“poolType”,”shape”)public class Pool(){ public String poolType; public String shape; …}

{poolType : “Inground”,}{poolType : “Inground”,shape : “Rectangle”}

JSR 367

Page 49: Java EE 8 Update

Java EE Security• Improve Java EE platform by ensuring that the security

API is useful in the modern cloud/PaaS paradigm• Simplify, standardize, modernize• Promotes modern concepts (EL and CDI)

JSR 367

Page 50: Java EE 8 Update

Java EE Security• Simplify security providers• Easy pluggability and mapping• Enabling existing security annotations for all beans• Proposed examples:

• https://github.com/javaee-security-spec/javaee-security-proposals

JSR 375

Page 51: Java EE 8 Update

Java EE Security: Proposed Provider@SecurityProviderpublic class MySecurityProvider { @Inject UserService userService; @OnAuthentication // The parameters could 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. }}

JSR 375

Page 52: Java EE 8 Update

Java EE Security – JavaOne 2016• Add OAuth and OpenID support• Secret management

JSR 375

Page 53: Java EE 8 Update

JCache• Java Temporary Caching API• JSR 107 - Started in 2001• Provides a common way for Java applications to create,

access, update, and remove entries from caches

JSR 197

Page 54: Java EE 8 Update

JCache• Provide applications with caching functionality…

particularly the ability to cache Java objects• Define common set of caching concepts & facilities• Minimize learning curve• Maximize portability• Support in-process and distributed cache implementations

JSR 107

Page 55: Java EE 8 Update

Others: Not Addressed• JPA• WebSocket• Concurrency Utilities• Batching• etc…

Page 56: Java EE 8 Update

PROPOSED JSRS

Page 57: Java EE 8 Update

Configuration• Standardize a mechanism of defining, injecting and using

configuration within an application.• Define configuration persistence mechanisms, formats,

and bindings.• Support for merging, overriding, and federating

configurations from different sources• Provide a standard mechanism for working with

mutable/dynamic configurations

Page 58: Java EE 8 Update

Health Check• Goal: Standardize health reporting• Proposed new REST API enabling health checking

• Available via configurable context (/healthcheck)• Will include semantics for reporting health

• Health status codes• Reasons/warnings• Health of dependencies

Page 59: Java EE 8 Update

Java EE Roadmap - JavaOne 20162016• Feedback through Survey• Launch Java EE Next JSRs2017• Java EE 8

• Specs, RI, TCK complete• Initial microservices support

• Define Java EE 9• Early access implementation of

Java EE 9

2018• Java EE 9

• Specs, RI, TCK complete

• Modular Java EE runtime

• Enhanced microservices support

Page 60: Java EE 8 Update

Java EE: Take Action• Start working with Java EE 8 today• Tools:

• GlassFish v5 (or Payara)• Tomcat 9 web sockets• Milestones• Examples and Specification Docs

Page 61: Java EE 8 Update

Java EE Resources• JavaOne 2016 EE 8 Update/Reboot

• http://tinyurl.com/zeark5t• Java EE 8 by Arjan Tijms

• https://javaee8.zeef.com/arjan.tijms• JavaOne 2016 Sessions

• https://www.oracle.com/javaone/• JSR 366

• https://www.jcp.org/en/jsr/detail?id=366

Page 62: Java EE 8 Update

Join Us!

https://javaee-guardians.io

Page 63: Java EE 8 Update

Adopt-A-JSR• Started in 2007, easy way for JUGs to get involved• What you can do depends upon what you want to do &

what spec leads are looking for

Write or speak about the technology!

Follow Expert Groups

Read early drafts/javadoc

Test early versions