Java EE 7 Technical Keynote

22
The Java EE Platform Technical Keynote Reza Rahman (@reza_rahman) Java EE/GlassFish Evangelist

description

Java EE technical keynote delivered at JavaOne Russia 2013.

Transcript of Java EE 7 Technical Keynote

Page 1: Java EE 7 Technical Keynote

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1

The Java EE Platform Technical Keynote

Reza Rahman (@reza_rahman)Java EE/GlassFish Evangelist

Page 2: Java EE 7 Technical Keynote

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

The 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 7 Technical Keynote

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

Java EE 7

JCA 1.7JCA 1.7

Managed Beans 1.0Managed Beans 1.0 EJB 3.2EJB 3.2

Servlet 3.1Servlet 3.1

PortableExtension

s

PortableExtension

s

JSF 2.2JSF 2.2 JAX-RS 2JAX-RS 2

JMS 2JMS 2JPA 2.1JPA 2.1

EL 3.0EL 3.0

JTA 1.2JTA 1.2

JSP 2.3JSP 2.3

Interceptors 1.1Interceptors 1.1 CDI 1.1CDI 1.1Common Annotations 1.1

Common Annotations 1.1

UpdatedMajorRelease

New

Java API for WebSocket(JSR 356)

Java API for WebSocket(JSR 356)

Batch Applications(JSR 352)

Batch Applications(JSR 352)

Java API for JSON(JSR 353)

Java API for JSON(JSR 353)

Concurrency Utilities(JSR 236)

Concurrency Utilities(JSR 236)

Page 4: Java EE 7 Technical Keynote

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

Java API for WebSocket

Full-duplex, bidirectional communication over HTTP– Part of HTML 5

API for WebSocket Client/Server– Declarative, annotation-driven

– Programmatic, interface-driven

Page 5: Java EE 7 Technical Keynote

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5

Java API for WebSocketConnection Life Cycle

@Singleton@ServerEndpoint(”/chat”)public class ChatServer { Set<Session> peers = ...

@OnOpen public void onOpen(Session peer) { peers.add(session); }

@OnClose public void onClose(Session session) { peers.remove(session); } ...

Page 6: Java EE 7 Technical Keynote

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

Java API for WebSocketWebSocket Communication

... @OnMessage public void message(String message, Session client) throws IOException { for (Session session : peers) { if (!session.equals(client)) { session.getRemote().sendObject(message); } } }}

Page 7: Java EE 7 Technical Keynote

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

Java API for JSON Processing

API to parse and generate JSON Streaming and Object Model APIs similar to StAX and DOM in the

XML world JSON Binding API forthcoming

– Along the lines of JAXB, as opposed to JSON-P

Page 8: Java EE 7 Technical Keynote

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

Java API for JSON ProcessingWriting JSON (Object Model API)

[

{

"type": "home”,

"number": "212 555-1234"

},

{

"type": "fax”,

"number": "646 555-4567"

}

]

JsonArray value =

Json.createArrayBuilder()

.add(Json.createObjectBuilder()

.add("type", "home")

.add("number", "212 555-1234")

)

.add(Json.createObjectBuilder()

.add("type", "fax")

.add("number", "646 555-4567")

)

.build();

Page 9: Java EE 7 Technical Keynote

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

JAX-RS 2

Client API Message filters & entity interceptors Asynchronous processing

– Server and client

Hypermedia Support Mime type negotiation

Page 10: Java EE 7 Technical Keynote

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

JAX-RS 2Client API

// Get instance of ClientClient client = ClientBuilder.newClient(); // Get customer name for the shipped productsString name = client.target(“../orders/{orderId}/customer”) .pathParam(”orderId", ”10”) .queryParam(”shipped", ”true”) .request() .get(String.class);

Page 11: Java EE 7 Technical Keynote

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11

JMS 2

API modernization– Streamlined APIs

– Dependency injection

– Runtime exceptions

– Builder pattern

– Intelligent defaults

Delivery delay, async send, delivery count MDB alignment JMS resource definition

Page 12: Java EE 7 Technical Keynote

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

JMS 2Old API@Resource(lookup = "java:global/jms/demoConnectionFactory")ConnectionFactory connectionFactory;@Resource(lookup = "java:global/jms/demoQueue")Queue demoQueue;

public void sendMessage(String payload) { try { Connection connection = connectionFactory.createConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer messageProducer = session.createProducer(demoQueue); TextMessage textMessage = session.createTextMessage(payload); messageProducer.send(textMessage); } finally { connection.close(); } } catch (JMSException ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); }}

Boilerplate

Functional core

Checked exceptions

Page 13: Java EE 7 Technical Keynote

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

JMS 2Simplified API

@Injectprivate JMSContext context;

@Resource(mappedName = "jms/inboundQueue")private Queue inboundQueue;

public void sendMessage (String payload) { context.createProducer().send(inboundQueue, payload);}

Reduced to functional core

Higher-level managed, injected API

Page 14: Java EE 7 Technical Keynote

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

Batch Applications for the Java Platform

Standard Java API for batch processing Lingua franca for well understood batch concepts

– Jobs, job specification language (JSL), steps, readers, writers, processors, chunking, flow, parallelization, repositories

Page 15: Java EE 7 Technical Keynote

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

<step id=”sendStatements”> <chunk reader ref=”accountReader” processor ref=”accountProcessor” writer ref=”emailWriter” chunk-size=”10” /></step>

Batch Applications for the Java Platform Step Example

...implements ItemReader {public Object readItem() { // read account using JPA}

...implements ItemProcessor {Public Object processItems(Object account) { // read Account, return Statement}

...implements ItemWriter {public void writeItems(List accounts) { // use JavaMail to send email}

Page 16: Java EE 7 Technical Keynote

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

Concurrency Utilities for Java EE

Provides low-level asynchronous processing capabilities to Java EE application components in a safe, reliable, consistent manner

Mostly extension of Java SE Concurrency Utilities APIs– ManagedExecutorService

– ManagedScheduledExecutorService

– ManagedThreadFactory

Page 17: Java EE 7 Technical Keynote

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17

Concurrency Utilities for Java EE Managed Task Executor

public class TestServlet extends HTTPServlet { @Resource(name=“concurrent/MyExecutorService”) ManagedExecutorService executor;

Future future = executor.submit(new MyTask());

class MyTask implements Runnable { public void run() { ... // Task logic } }}

Page 18: Java EE 7 Technical Keynote

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

Many others . . .

• JPA 2.1: Schema generation, stored procedures, converters…

• JSF 2.2: @FlowScoped, HTML5 forms, CDI alignment…

• Bean Validation 1.1: Method validation…

• Servlet 3.1: Non-blocking IO, Upgrade to WebSocket…

• EL 3.0: Lambda expressions, Collection, Operators…

• JTA 1.2: @Transactional, @TransactionScoped…

• CDI 1.1: Ordering of interceptors, Servlet events, @Veto…

• EJB 3.2: Optional CMP/BMP…

Page 19: Java EE 7 Technical Keynote

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

Java EE 8 and Beyond

Java EE 7

CDIAlignment

Multitenancy

NoSQL

JSON-B

ModularityCloud

JCache

HTML 5

Page 20: Java EE 7 Technical Keynote

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

Java EE 7 (WebSocket+JSON-P) Demo

https://blogs.oracle.com/reza/resource/whiteboard.zip

Page 21: Java EE 7 Technical Keynote

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

4.0Try it out!

download.java.net/glassfish/4.0/promoted/

Page 22: Java EE 7 Technical Keynote

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

More Java EE at JavaOne Russia…

Title Speakers Time - Location

Unlocking the Java EE Platform with HTML5 Geertjan Wielenga Tuesday 12:15 - 14:15 - Paris

The Java EE 7 Platform: Productivity++ and HTML5

Arun Gupta Tuesday 13:30 - 14:30 - Moscow

Java Message Service 2: New and Updated Reza Rahman Tuesday 15:30 - 16:30 - Moscow

Java API for RESTful Web services: New and Updated

Reza Rahman Tuesday 16:45 - 17:45 - San Francisco

Building WebSocket Applications using Java: JSR 356

Arun Gupta Wednesday 9:30 - 10:30 - San Francisco

Concurrency Utilities for Java EE Reza Rahman Wednesday 10:45 - 11:05 - San Paulo

Batch Applications for the Java Platform Reza Rahman Wednesday 11:50 - 12:10 - San Paulo

Getting Started with the Java EE 7 Platform Arun Gupta Wednesday 12:45 - 14:45 - Paris

Java API for JSON Processing Reza Rahman Wednesday 18:00 - 18:20 - San Paulo