Andrei Niculae - JavaEE6 - 24mai2011

Preview:

Citation preview

Java EE

The Evolution of a Platform

Andrei Niculae

Technology Presales Consultant

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.

2

Java EE 6 Overview

4

May 1998

JPE Project

Sep 2001 13 Specs

J2EE 1.3

CPM, Connector Architecture

May 2006 23 specs

Java EE 5

Ease ofDevelopment

Annotations

EJB 3.0

Persistence API

New andUpdatedWeb Services

Dec 1999 10 specs

J2EE 1.2

Servlet, JSP, EJB, JMS

Nov 2003 20 specs

J2EE 1.4

WebServices

Management

Deployment

Java EE 6

Pruning

Extensibility

Ease of Development

EJB Lite

RESTful WS

CDI

Managed Beans

Java EE Web

Profile

Dec 2009 28 specs

Java EE: Past & Present

Java EE 6 Goals

DeveloperProductivity

Flexible&

Lightweight Extensible

•Web Profile

•Pruning

• Embrace open source frameworks

• More annotations• POJO development• Less XML configuration

Java EE

What’s New in Java EE 6?

• Several new APIs

• Web Profile

• Pluggability / extensibility

• Dependency injection

• Lots of improvements to existing APIs

What's new in the Java EE 6 PlatformNew and updated components

• EJB 3.1(+Lite)

• JPA 2.0

• Servlet 3.0

• JSF 2.0

• JAX-RS 1.1

• Bean Validation 1.0

• DI 1.0

• CDI 1.0

• Connectors 1.6

• Managed Beans 1.0

• Interceptors 1.1

• JSP 2.2

• EL 2.2

• JSR 250 1.1

• JASPIC 1.1

• JACC 1.5

• JAX-WS 2.2

• JSR 109 1.3

EJB 3.1

• No interface view – one source file per bean

• Simple POJO

• Much simpler to declare/work with

• Singleton

• EJB Timers

EJB 3.1 Lite

A proper subset of the full EJB 3.1 API that includes a small, powerful selection of EJB features

What's new in the Java EE 6 PlatformNew and updated components

• EJB 3.1(+Lite)

• JPA 2.0

• Servlet 3.0

• JSF 2.0

• JAX-RS 1.1

• Bean Validation 1.0

• DI 1.0

• CDI 1.0

• Connectors 1.6

• Managed Beans 1.0

• Interceptors 1.1

• JSP 2.2

• EL 2.2

• JSR 250 1.1

• JASPIC 1.1

• JACC 1.5

• JAX-WS 2.2

• JSR 109 1.3

JPA 2.0Type-safe Criteria API

EntityManager em = getEntityManager();

CriteriaBuilder cb = em.getCriteriaBuilder();

CriteriaQuery<Employee> query =

cb.createQuery(Employee.class);

Root<Employee> employee = query.from(Employee.class);

query.where(cb.equal(employee.get("firstName"),

"Bob"));

List<Employee> result =

em.createQuery(query).getResultList();

What's new in the Java EE 6 PlatformNew and updated components

• EJB 3.1(+Lite)

• JPA 2.0

• Servlet 3.0

• JSF 2.0

• JAX-RS 1.1

• Bean Validation 1.0

• DI 1.0

• CDI 1.0

• Connectors 1.6

• Managed Beans 1.0

• Interceptors 1.1

• JSP 2.2

• EL 2.2

• JSR 250 1.1

• JASPIC 1.1

• JACC 1.5

• JAX-WS 2.2

• JSR 109 1.3

Servlets 3.0

Servlets 3.0Extensibility

• Plugin libraries using web fragments• Modular web.xml

• Bundled in framework JAR file in META-INF Directory

• Zero-configuration, drag-and-drop for web Frameworks

• Servlets, servlet filters, context listeners for a framework get discovered and registered by the container

What's new in the Java EE 6 PlatformNew and updated components

• EJB 3.1(+Lite)

• JPA 2.0

• Servlet 3.0

• JSF 2.0

• JAX-RS 1.1

• Bean Validation 1.0

• DI 1.0

• CDI 1.0

• Connectors 1.6

• Managed Beans 1.0

• Interceptors 1.1

• JSP 2.2

• EL 2.2

• JSR 250 1.1

• JASPIC 1.1

• JACC 1.5

• JAX-WS 2.2

• JSR 109 1.3

Bean Validation

• Tier-independent mechanism to define constraints for data validation

• @NotNull(message=”...”), @Max, @Min, @Size

• Integrated with JSF and JPA

• JSF: f:validateRequired, f:validateRegexp

• JPA: pre-persist, pre-update, and pre-remove

• Fully Extensible

What's new in the Java EE 6 PlatformNew and updated components

• EJB 3.1(+Lite)

• JPA 2.0

• Servlet 3.0

• JSF 2.0

• JAX-RS 1.1

• Bean Validation 1.0

• DI 1.0

• CDI 1.0

• Connectors 1.6

• Managed Beans 1.0

• Interceptors 1.1

• JSP 2.2

• EL 2.2

• JSR 250 1.1

• JASPIC 1.1

• JACC 1.5

• JAX-WS 2.2

• JSR 109 1.3

Context and Dependency Injection (CDI)

• Opt-in technology on a per-module basis– META-INF/beans.xml

– WEB-INF/beans.xml

• @Resource only for container-provided objects

• Use @Inject for application classes

@Inject @LoggedIn User user;

Context and Dependency Injection (CDI)

• Managed beans on steroids

• Opt-in technology on a per-module basis– META-INF/beans.xml

– WEB-INF/beans.xml

• @Resource only for container-provided objects

• Use @Inject for application classes

@Inject @LoggedIn User user;

The type describes the capabilities (methods)

Context and Dependency Injection (CDI)

• Managed beans on steroids

• Opt-in technology on a per-module basis– META-INF/beans.xml

– WEB-INF/beans.xml

• @Resource only for container-provided objects

• Use @Inject for application classes

@Inject @LoggedIn User user;

Qualifiers describes qualities/characteristics/identity

What's new in the Java EE 6 PlatformNew and updated components

• EJB 3.1(+Lite)

• JPA 2.0

• Servlet 3.0

• JSF 2.0

• JAX-RS 1.1

• Bean Validation 1.0

• DI 1.0

• CDI 1.0

• Connectors 1.6

• Managed Beans 1.0

• Interceptors 1.1

• JSP 2.2

• EL 2.2

• JSR 250 1.1

• JASPIC 1.1

• JACC 1.5

• JAX-WS 2.2

• JSR 109 1.3

Managed Beans

• Plain Java objects (POJOs)

• Foundation for other component types

• Fully support injection (@Resource,

@Inject)

• @PostConstruct, @PreDestroy

callbacks

• Optional name

Sample Managed Beans

@ManagedBean

public class SpaceCapsule {

@Resource

DataSource configDB;

public launch() {

// ...

}

}

@ManagedBean("yuri")

public class Cosmonaut

{

@Resource

SpaceCapsule vostok;

@PostConstruct

orbitEarth() {

// ...

}

}

UniformityCombination of annotations "just work"

• Example: JAX-RS resource classes are POJOs

• Use JAX-RS-specific injection capabilities

• But you can turn resource classes into managed

beans or EJB components ...

• ... and use all new services !

JAX-RS SampleUsing JAX-RS injection annotations

@Path("root")

public class RootResource {

@Context UriInfo ui;

public RootResource() { ... }

@Path("{id}")

public SubResource find(@PathParam("id") String id) {

return new SubResource(id);

}

}

JAX-RS SampleAs a managed bean, using @Resource

@Path("root")

@ManagedBean

public class RootResource {

@Context UriInfo ui;

@Resource DataSource myDB;

public RootResource() { ... }

@Path("{id}")

public SubResource find(@PathParam("id") String id) {

return new SubResource(id);

}

}

JAX-RS SampleAs an EJB, using @Resource and security annotations

@Path("root")

@Stateless

public class RootResource {

@Context UriInfo ui;

@Resource DataSource myDB;

public RootResource() { ... }

@Path("{id}")

@RolesAllowed("manager")

public SubResource find(@PathParam("id") String id) {

return new SubResource(id);

}

}

JAX-RS SampleAs a CDI bean, using @Inject and scope annotations

@Path("root")

@ApplicationScoped

public class RootResource {

@Context UriInfo ui;

@Inject @CustomerDB DataSource myDB;

@Inject @LoggedIn User user;

public RootResource() { ... }

@Path("{id}")

public SubResource find(@PathParam("id") String id) {

// ...

}

}

How to Obtain UniformityCombination of annotations "just work"

• Annotations are additive

• New behaviors refine pre-existing ones

• Strong guidance for new APIs

Classes can evolve smoothly

Java EE 6 Web ProfileNew, updated components and unchanged components

• EJB 3.1 Lite

• JPA 2.0

• Servlet 3.0

• JSF 2.0

• Bean Validation 1.0

• DI 1.0

• CDI 1.0

• Managed Beans 1.0

• Interceptors 1.1

• JSP 2.2

• EL 2.2

• JSR 250 1.1

• JSR-45 1.0

• JSTL 1.2

• JTA 1.1

JEE BenefitsA Better Platform

• Less boilerplate code than ever

• Fewer packaging headaches

• Uniform use of annotations

• Sharing of resources to avoid

duplication

• Dependency Injection

• Strongly-typed decorators

• ... and more!

Future Java EE

Java EE for the Cloud

• Applications are versioned

• Multiple versions can coexist

• Must deal with data versioning, upgrades, etc.

• Need ability to specify QoS properties

• Applications both expose and connect to services

• Common management and monitoring interfaces

• Evolution, not revolution

Cloud Platform

Application

Virtualization Layer

State Management

JavaService

PersistenceService

QueueingService

Cloud Platform

Application

CodeModule

CodeModule

Schema MigrationQoS

InformationSecurity

CodeModule

Virtualization Layer

State Management

JavaService

PersistenceService

QueueingService

Cloud Platform

Application Application Application

Virtualization Layer

State Management

JavaService

PersistenceService

QueueingService

Cloud Platform

Application Application Application Application Application

Virtualization Layer

State Management

JavaService

PersistenceService

QueueingService

Cloud Platform

Managed Environment

Application Application Application

Virtualization Layer

State Management

JavaService

PersistenceService

QueueingService

Application Application

Java EE 7 Content (so far)

• Filed and voted !– Java EE 7 (JSR 342)

– JPA 2.1 (JSR 338)

– JAX-RS 2.0 (JSR 339)

– Servlet 3.1 (JSR 340)

– JSF 2.2 (JSR 344)

– EL 3.0 (JSR 341)

– JMS 2.0 (JSR 343)

Java EE 7 Content (so far)

• Other– JCache revived (JSR 107)

– Concurrency Utilities (236)

– MRs: JSR250, JAX-WS 2.3, JTA 1.2, JSP 2.3, connectors

– EJB 3.2

– Bean Validation 1.1

– JSR-330 1.1

– CDI 1.1

• Yet to be filed– JSON 1.0

Java EE 7 - When?

• Late 2012

• Date-driven release

– (anything not ready will be deferred to Java EE 8)

• Participate !

– Expert Groups still forming, consider joining

– JCP membership free for individuals

Java EE 6 Platform

Available Today

http://www.oracle.com/javaee

Recommended