Down and Dirty with Java EE 7 - Jfokus and Dirty with Java EE 7 Reza Rahman Java EE/GlassFish...

Preview:

Citation preview

Down and Dirty with Java EE 7

Reza Rahman

Java EE/GlassFish Evangelist

Reza.Rahman@Oracle.com

@reza_rahman

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

Program Agenda

Java EE 7

Cargo Tracker

The API Changes + The Code!

Looking Ahead…

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

Java EE Past, Present and Future

J2EE 1.3

CMP,

Connector

Architecture

J2EE 1.4

Web

Services

Mgmt,

Deployment,

Async

Connector

Java EE 5

Ease of

Development,

EJB 3, JPA,

JSF, JAXB,

JAX-WS,

StAX, SAAJ

Java EE 6

Pruning,

Extensibility,

Ease of Dev,

JAX-RS

CDI

Validation

Web Profile

Servlet 3,

EJB 3.1 Lite

Java EE 7 JMS 2,

Batch, TX,

Concurrency,

Interceptor

WebSocket JSON

Web Profile JAX-RS 2

JAX-RPC,

CMP/ BMP,

JSR 88

J2EE 1.2

Servlet, JSP,

EJB, JMS,

RMI

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

Java EE 7

Connector

1.6

Managed Beans 1.0 EJB 3.2

Servlet 3.1

Portable

Extension

s

JSF 2.2 JAX-RS

2.0

Bean

Valid

ati

on

1.1

JMS 2.0 JPA 2.1

EL 3.0

JTA 1.2

JSP 2.2

Interceptors 1.1 CDI 1.1

Common

Annotations

1.1

Updated Major

Release

New

Concurrency Utilities

(JSR 236)

Batch Applications

(JSR 352)

Java API for JSON

(JSR 353)

Java API for WebSocket

(JSR 356)

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

Java EE in Action

http://cargotracker.java.net

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

JMS 2

API modernization

– Dependency injection

– Fluent APIs

– Intelligent defaults

– Unchecked exceptions

New features

– Delivery delay, async send

Platform alignment

– MDB activation properties, JMS resource definition

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

Java API for WebSocket

High level API for HTML 5 WebSockets

– Full-duplex TCP-like communication on the Web utilizing HTTP

Both client and server-side (Java SE and Java EE)

Both declarative and programmatic

Pluggable and extensible

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

Java API for JSON Processing

Low level API to parse, generate, transform, query JSON

– JSON equivalent of JAXP

Object Model and Streaming API

– Similar to DOM and StAX

Binding JSON to Java objects forthcoming

– JSON equivalent of JAXB

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

Bean Validation 1.1

Method constraints

– Very useful for JAX-RS and WebSocket

CDI Alignment

– All Bean Validation artifacts now injection capable

EL 3 integration

– More expressive validation messages

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

JAX-RS 2

Client API

Message Filters & Entity Interceptors

– Servlet filters and CDI interceptors for JAX-RS

– Common configuration

Asynchronous Processing – Server & Client

Hypermedia support

– Transitional and structural links

Content negotiation

Bean Validation 1.1 integration

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

JPA 2.1

Schema generation

Stored procedures

Unsynchronized persistence contexts

Entity Graphs

Entity converters

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

JSF 2.2

HTML5 Support

– Pass-through elements and attributes

Managed beans deprecated/CDI alignment

– @ViewScoped for CDI

@FlowScoped

Stateless views

Resource library contracts

View actions

File upload component

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

Batch Applications for the Java Platform

API for robust batch processing targeted to Java EE, Java SE

Common architecture

– Operator, repository, job, step, reader-processor-writer pattern

Common features

– Chunking, check-pointing, transactions, retries, exceptions, workflow,

parallelism

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

Concurrency Utilities for Java EE

Provides simple, safe API for concurrency in Java EE

Builds on Java SE concurrency

– ManageExecutorService

– ManagedScheduledExecutorService

– ManagedThreadFactory

Relatively low-level API

Important enabler for Java EE ecosystem

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

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

}

}

}

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

Yet More…

JTA 1.2

– @Transactional, @TransactionScoped

EL 3.0

– Standalone API, lambda expressions, collections, operators

Servlet 3.1

– Non-blocking I/O, upgrade to WebSocket, security

CDI 1.1

– Global enablement, @AroundConstruct, @Vetoed

EJB 3.2

– Truncating CMP/BMP

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

Java EE 8

JSON-B

JCache

CDI 2

More CDI/EJB alignment

JMS.next()?

Security

Testability

Cloud, PaaS, multitenancy/SaaS

Action-oriented Web framework/HTML 5 alignment?

NoSQL?

Modularity?

http://glassfish.org/survey

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

Try it Out!

4.0

http://download.java.net/glassfish/4.0/release/glassfish-4.0.zip

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

Resources

Java EE Tutorials

– http://docs.oracle.com/javaee/7/tutorial/doc/home.htm

Digging Deeper

– http://docs.oracle.com/javaee/7/firstcup/doc/home.htm

– https://glassfish.java.net/hol/

– https://java.net/projects/cargotracker/

Java EE 7 Transparent Expert Groups

– http://javaee-spec.java.net

Java EE 7 Reference Implementation

– http://glassfish.org

The Aquarium

– http://blogs.oracle.com/theaquarium

Recommended