what's coming in java ee 8

40
Others Talk, We Listen. Java EE 8 and Java EE 9 - What You Need to Know! Reza Rahman Senior Architect [email protected] @reza_rahman

Upload: reza-rahman

Post on 02-Jul-2015

14.822 views

Category:

Technology


6 download

DESCRIPTION

Java EE 7 is here and the horizons for Java EE 8 are emerging. In order to solidly kick start Java EE 8, the GlassFish team conducted a series of community surveys. This session shares the content, results and analysis of these surveys. We will also share the detailed progress of Java EE 8 technologies already underway. The goal is to foster interest, discussion and participation around Java EE 8. Some of the items covered include HTTP 2, Server-Sent Events (SSE), JSON binding, JCache, CDI/EJB alignment, cloud, PaaS, multitenancy/SaaS, JMS 2.1, JAX-RS 2.1, CDI 2, security simplification, REST management/monitoring, an action-oriented Web framework and much, much more. You are encouraged to bring your questions, comments and ideas. The time to get involved in shaping the future of Java EE is now!

TRANSCRIPT

Page 1: What's Coming in Java EE 8

Others Talk, We Listen.

Java EE 8 and Java EE 9 - What You Need to Know!Reza RahmanSenior [email protected]@reza_rahman

Page 2: What's Coming in Java EE 8

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.

Page 3: What's Coming in Java EE 8

J2EE 1.3

CMP,JCA

J2EE 1.4

Web Services, Mgmt, Deplymnt

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

Page 4: What's Coming in Java EE 8

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

Page 5: What's Coming in Java EE 8

Java EE Ecosystem

Copyright © 2015 CapTech Ventures, Inc. All rights reserved.

Page 6: What's Coming in Java EE 8

Microservices and Java EE

Copyright © 2015 CapTech Ventures, Inc. All rights reserved.

http://microprofile.io

Page 7: What's Coming in Java EE 8

Java EE 8 Community Survey

Copyright © 2015 CapTech Ventures, Inc. All rights reserved.

https://java.net/downloads/javaee-spec/JavaEE8_Community_Survey_Results.pdf

Page 8: What's Coming in Java EE 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.

Page 9: What's Coming in Java EE 8

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.

Page 10: What's Coming in Java EE 8

• 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-BJava API for JSON Binding

Page 11: What's Coming in Java EE 8

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"

}

}

Page 12: What's Coming in Java EE 8

• 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

Page 13: What's Coming in Java EE 8

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"}}

]

Page 14: What's Coming in Java EE 8

• 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"}

]

Page 15: What's Coming in Java EE 8

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);

Page 16: What's Coming in Java EE 8

• 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)

Page 17: What's Coming in Java EE 8

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();

...

});

}

}

Page 18: What's Coming in Java EE 8

• 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

Page 19: What's Coming in Java EE 8

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", ...)

Page 20: What's Coming in Java EE 8

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.

}

}

Page 21: What's Coming in Java EE 8

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();

}

}

Page 22: What's Coming in Java EE 8

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);

Page 23: What's Coming in Java EE 8

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.

Page 24: What's Coming in Java EE 8

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) {

Page 25: What's Coming in Java EE 8

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.

Page 26: What's Coming in Java EE 8

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) {

...

}

}

Page 27: What's Coming in Java EE 8

• 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

Page 28: What's Coming in Java EE 8

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);

}

}

Page 29: What's Coming in Java EE 8

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.

Page 30: What's Coming in Java EE 8

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 {

...

Page 31: What's Coming in Java EE 8

Date/Time API with JPA

Copyright © 2015 CapTech Ventures, Inc. All rights reserved.

@Entity

public class Accident {

@Temporal(TemporalType.TIMESTAMP)

@Past

private Instant when;

}

Page 32: What's Coming in Java EE 8

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);

Page 33: What's Coming in Java EE 8

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.

Page 34: What's Coming in Java EE 8

Java EE Guardians

http://javaee-guardians.io

@javaee_guardian

Copyright © 2015 CapTech Ventures, Inc. All rights reserved.

Page 35: What's Coming in Java EE 8

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

Page 36: What's Coming in Java EE 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.

Page 37: What's Coming in Java EE 8

Java EE 8/9 Roadmap

Copyright © 2015 CapTech Ventures, Inc. All rights reserved.

Page 38: What's Coming in Java EE 8

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.

Page 39: What's Coming in Java EE 8

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.

Page 40: What's Coming in Java EE 8

Copyright © 2015 CapTech Ventures, Inc. All rights reserved.