java ee for the cloud

46
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Java EE for the Cloud Dmitry Kornilov JSONB/P Specification Lead Oracle @m0mus October 20, 2016

Upload: dmitry-kornilov

Post on 16-Apr-2017

652 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Java EE for the Cloud

Dmitry KornilovJSONB/P Specification LeadOracle

@m0musOctober 20, 2016

Page 2: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 2

Safe Harbor StatementThe 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.

Page 3: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 3

Program Agenda

Road to Java EE 8

Proposed Shift in Focus

Java EE 8 Revised Proposal

Java EE 9 Proposal

Q & A

1

2

3

4

5

Page 4: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 4

Road to Java EE 8

J2EE 1.2

J2EE 1.3

J2EE 1.4

Java EE 5

Java EE 6

Java EE 7

1999 2001 2003 2006 2009 2013

Servlet, JSP, EJB, JMS, JTA, RMI-IIOP

EJB 2.0, JSTL, JAAS, JCA

EJB 2.1, WebServices, JAXP, JSF, JMX,Deployment

EJB 3.0, JPA, JAX-WS, JAXB, SAAJ, StAX

JAX-RS, Servlet 3.0, EJB 3.1, JPA 2.0, CDI, BV

JAX-RS 2.0,WebSocket, JSON-P, Concurrency, JMS 2.0

Page 6: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 6

Java EE 7

Connector JAXBJSP Debugging

Managed BeansJSPConcurrency EE Interceptors JAX-WS WebSocket

Bean Validation JASPIC ServletJMS JTADeployment

Batch JACCDependency Injection JAXR JSTL Management

CDI EJB JAX-RPC Web ServicesJSF Java Persistence

JSON-PCommon Annotations EL JAX-RS Web Services MetadataJavaMail

CDI

JSON-P

MVC

Bean Validation

JSF

JAX-RS

JSP

Servlet

Java EE 8 (Original Proposal, 2014)

JSON-B Security

Page 7: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 7

“The world has changed. I see it in the water. I feel it in the Earth. I smell it in the air...”

– J.R.R. Tolkien

Page 8: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted

8

Java EE - Available On Premise and in the Cloud

05/03/2023

Cloud

On Premise

WebSphere WebLogicRed Hat JBoss

8Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

Choice of Implementations

David Delabassee
Need to replace JCS logo with Mike's "Oracle PaaS Logo"
Page 9: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 9

Java EE APIs - Backbone of Leading Open Source Projects

Java EE Containers

Microservices WebContainers

WebFrameworks

PaaSREST

Page 10: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 10

Java EE + Cloud• More demanding business requirements• Move to the Cloud for agility & flexibility• Shift from physical infrastructure to virtual• Microservices vs. monolithic applications• Runtime packaged with applications

Page 11: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Cloud Development

Heterogeneous Clients• Mobile, REST, HTML5

Stateless Services• Managed and scaled

independently

Data Sources• Relational, non-relational

User profile service

Order service

Partnerservice

Catalog service

Notification service

Import service

HTTP/2 REST JSON XHR

Event JAX-RS/JSON Notifications JAX-WS

RDBMS NoSQL DB TSDBData Streams

Time SeriesEventsKey ValueJDBC

11

Page 12: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 12

It's Confusing!

Too many choices...Which components?

Overall architecture?

Standards?

Vendor commitment?

Page 13: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 13

Proposed Enhancements to Java EE• New AppDev style for Cloud and Microservices• Build on proven technologies• Comprehensive– Programming Model, Packaging, Portability

• Standards-based– This is a proposal only–Will work with the community and follow the JCP process

Page 14: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 14

Designed for Agility and Scalability with Security• Programming Model– Reactive programming– Unified event model

• Eventual Consistency– Automatically event out changes to observed data structures– Data sources with manageable consistency

• NoSQL– Persistence and query interface for Key Value and Document DB

• Security– Support of OAuth2, OpenID Connect– Secret management

App

App

App

App

Page 15: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 15

Location Transparency and Resiliency• Configuration– Externalized configuration– Multiple configuration sources

• State– API for external state

• Resiliency– Circuit breakers– Health check API

Reliability, Monitoring

Container Management

Scheduling & Elastic Scaling

Key Value

Database

Logging

Configuration

State

Security

Notification

User profile service

Order service

Catalog service

Page 16: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 16

Packaging and Simplicity• Packaging– Package applications, runtimes into containers– Standalone immutable executable binary– Multi-artifact archives– Leveraging Java 9 module system

• Serverless– Ephemeral instantiation

• Multitenancy– Increased density– Tenant-aware

App

ServerOrder

service

App

ServerCatalog service

Page 17: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Recent Java EE 7 compatibility updates: Congratulations! Technical Focus Areas

17

Extend for reactive programming

Unified event model Event messaging API JAX-RS, HTTP/2, Lambda,

JSON-B, ...

Programming Model

API to store externalized state

Automatically event out changes to observed data structures

Extension to support client-side circuit breakers

Resilient commands Standardize on client-side

format for reporting health

New spec – interfaces, packaging format, manifest

Ephemeral instantiation

Secret management OAuth OpenID

Package applications, runtimes into services

Standalone immutable executable binary

Multi-artifact archives

Increased density Tenant-aware routing and

deployment

Externalize configuration Unified API for accessing

configuration

Persistence and query interface for key value and document DB

Key Value/Doc Store Configuration Resiliency

Packaging

Eventual Consistency

Serverless

Multitenancy

State

Security

Page 18: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 18

Engage Java EE Community• Feedback through Survey• Launch Java EE Next JSRs

2016Java EE 8 • Specs, RI, TCK complete • Initial microservices support • Define Java EE 9 • Early access implementation

of Java EE 9

Java EE 9• Specs, RI, TCK complete• Modular Java EE runtime • Enhanced microservices

support

Java EE Roadmap

2017

2018

Page 19: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 19

We Are Hiring• Senior Java Developer–Work on JAX-RS, HTTP/2 and Servlet projects– Participate in specifications development–Working on Reference Implementations and TCKs– Participate in community reviews, forums, mailing lists– Strong experience in Java and Java EE (5+ years)– Full description

• Contacts– [email protected]

Page 20: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 20

We Need Your Feedback

Take the Java Community Surveyhttp://glassfish.org/survey

Page 21: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 21

Java EE 8 Revised Proposal JSON <-> object mapping

JSON-B 1.0 (JSR 367)

No ChangeProposed to DropProposed to Add

JSON Pointer JSON Patch Java 8 Lambda support

JSON-P 1.1 (JSR 374) Reactive enhancements Server-sent events Non-blocking I/O Client-side circuit breakers

JAX-RS 2.1 (JSR 370) HTTP/2 support

Servlet 4.0 (JSR 369)

Small-scale new features Community-driven improvements

JSF 2.3 (JSR 372) Action-based MVC framework

MVC 1.0 (JSR 371) Bootstrap API for Java SE Asynchronous events Observer ordering

CDI 2.0 (JSR 365) Collection constraints Date/Time support Community-requested features

Bean Validation 2.0 (JSR 380)

Authentication/authorization APIs OAuth support OpenID support Secret management

Security 1.0 (JSR 375) REST-based APIs

Management 2.0 (JSR 373) Flexible JMS MDBs Improved XA support

JMS 2.1 (JSR 368)

Externalized configuration Multiple configuration sources Layering and overrides

Configuration Client-side health checking

Health Checking

Page 22: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 22

Java EE 7

Connector JAXBJSP Debugging

Managed BeansJSPConcurrency EE Interceptors JAX-WS WebSocket

Bean Validation JASPIC ServletJMS JTADeployment

Batch JACCDependency Injection JAXR JSTL Management

CDI EJB JAX-RPC Web ServicesJSF Java Persistence

JSON-PCommon Annotations EL JAX-RS Web Services MetadataJavaMail

CDI

JSON-P

Security

Bean Validation

JSF

JAX-RS

JSP

Servlet

Health CheckConfiguration

Java EE 8 (Revised Proposal, 2016)

JSON-B

Page 23: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 23

JSON-P 1.1• Update JSON-P spec to stay current with emerging standards (RFC 7159)• Support for IETF standards on – JSON Pointer (RFC 6901)– JSON Patch (RFC 6902)– JSON Merge Patch (RFC 7396)

• Add editing/transformation operations to JSON objects and arrays• Support for a streaming API, together with Collectors• Support for processing big JSON, e.g. add filters to JSON parsing.

Page 24: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 24

JSON Pointer SampleJsonArray dogs = . . .;JsonPointer pointer = Json.createPointer("/1/breed");JsonValue breed = pointer.getValue(dogs);p.replace(dogs, Json.createValue("English Bulldog"));

[ { "name": "Cassidy", "breed": "English Bulldog", "age": 6 }, { "name": "Falco", "breed": "Pug", "age": 4 }]

Page 25: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 25

JSON Patch Sample• Modify Parts of JSON document• Patch is a JSON document itself• Operations:– Add, replace, remove, move, copy, test

[ { "name": "Cassidy", "breed": "English Bulldog", "age": 6 }, { "name": "Falco", "breed": "Pug", "age": 4 }, { "name": "Funes", "breed": "Frenchie", "age": 2 }]

[ { "op": "replace", "path": "/1/breed", "value": "English Bulldog" }, { "op": "remove", "path": "/2" }]

Page 26: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 26

JSON-B 1.0• API to serialize/deserialize Java objects to/from JSON documents– Similar to JAX-B– Standardizes the current technologies (Jackson, Genson, Gson)

• Default mapping between classes and JSON• Customization APIs– Annotations (@JsonbProperty, @JsonbNillable)– Runtime configuration builder

• Natural follow on to JSON-P– Closes the JSON support gap– Allows to change providers

Page 27: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 27

JSON-B SampleDog dog1 = new Dog();dog1.setName("Cassidy");dog1.setBreed("English Bulldog");dog1.setAge(6);

Dog dog2 = new Dog();dog2.setName("Falco");dog2.setBreed("English Bulldog");dog2.setAge(4);

List<Dog> dogs = new ArrayList<>();dogs.add(dog1);dogs.add(dog2);

Jsonb jsonb = JsonbBuilder.create();jsonb.toJson(dogs);

[ { "name": "Cassidy", "breed": "English Bulldog", "age": 6 }, { "name": "Falco", "breed": "English Bulldog", "age": 4 }]

Page 28: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 28

CDI 2.0• Define behavior of CDI outside of a Java EE container• Make CDI more modular to help other Java EE specs better integrate with it– Core CDI– CDI in Java SE– CDI in Java EE

• API to bootstrap a CDI container in Java SE• Observer ordering• Asynchronous event firing

Page 29: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 29

JAX-RS 2.1• Server-sent events• Non-blocking I/O in providers (filters, interceptors…)• Reactive programming paradigm to improve JAX-RS asynchronous clients• Hypermedia API enhancements• Integration with other JSRs and frameworks• Circuit breakers

Page 30: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 30

SSE – Server Code@Path("tickers")public class StockTicker { @Resource ManagedExecutorService executor;

@GET @Produces("text/event-stream") public EventOutput getQuotes() { EventOutput output = new EventOutput();

executor.execute(() -> { ... output.send(new StockQuote(...)); ... });

return output; }}

Page 31: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 31

SSE – Client CodeWebTarget target = client.target("http://example.com/tickers");

EventSource eventSource = new EventSource(target) { @Override public void onEvent(InboundEvent inboundEvent) { StockQuote quote = inboundEvent.readData(StockQuote.class); ... }};

eventSource.open();

Page 32: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 32

Servlet 4.0• Support for HTTP/2– Request/response multiplexing– Server push– Upgrade from HTTP 1.1

• Compatibility with latest HTTP 1.1 RFCs• Smaller community-requested improvements (JIRA issues)

Page 33: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 33

JSF 2.3• Better CDI integration• WebSocket integration• Ajax method invocation• Class-level Bean Validation• Java Date/Time support

Page 34: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 34

Java EE Security 1.0• API for managing users and groups• Simple security providers• Support for password aliasing• API for role mapping• Metadata and API for authentication• Interceptors for authorization, with CDI support• OAuth and OpenID Connect support• Secret management

Page 35: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 35

Simple Security Providers@EmbedddedSecurityProvider({ @Credentials(username="user1", password="password", roles="admin"), @Credentials(username="user2", password="password", roles="user")})

@DatabaseSecurityProvider( lookup="java:global/MyDB", userQuery="SELECT password FROM principals WHERE username=?", rolesQuery="SELECT role FROM roles where username=?", ...)

@LdapSecurityProvider(url="...", dnPrefix="...", dnSuffix="...", ...)

Page 36: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 36

Bean Validation 2.0• Constraints applied to collection elements• Support for new Date/Time API• Integration with Optional wrappers• Repeatable annotations• Additional features requested from community

Page 37: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 37

Java EE Configuration• Unified API• Externalized configuration• Support of multiple configuration sources– Properties, xml and json

• Layering and overrides• Optional configuration descriptor• Dynamic configuration• Integration with other Java EE frameworks

Java EE Config

XML JSONprop

DBweb

Application

Page 38: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 38

Java EE Configuration• Unified API• Externalized configuration• Support of multiple configuration sources– Properties, xml and json formats support out of the box

• Layering and overrides

Java EE 8

• Optional configuration descriptor• Dynamic configuration• Integration with other Java EE frameworks

Java EE 9

Page 39: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 39

API

a=JavaOneb=9c=2016

Config config = ConfigProvider.getConfig();

// Returns "JavaOne"String a = config.getProperty("a");

// Returns string "9"String b = config.getProperty("b");

// Returns nullString notExists = config.getProperty("not.exist");

// Returns string "default"String notExistsDefault = config.getProperty("not.exist","default");

// Returns number 2016Long c = config.getProperty("c", Long.class);

Page 40: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 40

Defining Configuration Sources• Using config.sources runtime parameter

• Using API

• Using config-sources.xml

java –jar my.jar –Dconfig.source=/cfg/config.json,http://shared/global.xml

Config config = ConfigProvider.builder() .addSource(new FileSource("/cfg/config.json"), 200) .addSource(new WebSource("http://shared/global.xml"), 100) .build();

<config-sources> <source>/cfg/config.json</source> <source>http://shared/config.xml</source></config-sources>

Page 41: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 41

Health Check• Standard health-check end-point– <service>/management/health– Services can choose to over-ride default location

• Define a format of health-check – JSON, XML

• Health-check Java API– Annotations– Lightweight Java API

Page 42: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 42

Health Check Samplepublic class MyHealthContributor { // Variant example which does not take a HealthContext. // Directly callable with REST @HealthProvider @Path("bar") @GET public Health contributeHealthSummary() { Health health = new Health();     ... return health; }}

Page 43: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 43

Eventing API• Make event producer and consumer as top level configurable, injectable

objects• Be able to send and receive events synchronously and asynchronously• Incorporate reactive style in API– Use Java 9 Flow for batched asynchronous event sending

• Be able to programmatically start and stop asynchronous event consumer• Provide pluggability of underlying messaging system– Kafka, ZeroMQ, RabbitMQ

• Integration with Java EE Configuration API

Page 44: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 44

Eventing API Example@Inject @EventConfig(configkey="myeventconfig")EventProducer producer;

public void someMethod() { producer.sendEvent("My event: hello");}

@Inject @EventConfig(configkey="myeventconfig")EventConsumer consumer;

public void someMethod() { System.out.println(consumer.receiveEvent(1000L));}

Page 45: Java EE for the Cloud

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 45

Q & A

Page 46: Java EE for the Cloud