javaee6 overview

Download Javaee6 Overview

If you can't read please download the document

Upload: carol-mcdonald

Post on 16-Apr-2017

3.981 views

Category:

Technology


0 download

TRANSCRIPT

Carol McDonald

Java EE 6: The Next Generation Enterprise Application Platform

Topics

Java EE 6 themesRight-sizing, Extensibility, Ease of development

Java EE 6 TechnologiesManaged Beans & Interceptors

Bean validation

DI (JSR-330) and CDI (JSR-299)

JPA 2.0

Servlet 3.0

EJB 3.1

JSF 2.0

JAX-RS 1.1

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JAVA EE 6

FINAL RELEASEDECEMBER 10, 2009

Java EE 6 Themes

A brief history

May 1998

Project JPE

Dec 199910 specs

J2EE 1.2

EnterpriseApplication

ServletJSPEJBJMSRMI/IIOP

Sept 200113 specs

J2EE 1.3

RobustScalable

CMPJCA

Nov 200320 specs

J2EE 1.4

Web Services

WSManagementDeployment

May 200623 specs

Java EE 5

Ease ofdevelopment

AnnotationsEJB 3JPA 1.0WS-*JSF

Q4 200928 specs

Java EE 6

Right-sizing

EJB 3.1JPA 2.0Servlet 3.0JSF 2.0JAX-RS 1.1JCDI 1.0@InjectBean Validat

Web Profile

ManagedBean

Right-sizingProfiles & Pruning

Use only what you need

Web profile, EJB Lite

Extensibility (Pluggability)Use 3rd-party frameworks or libraries without extra configuration

Ease of developmentDefault over configuration

Dependency Injection (DI)

Major Themes of Java EE 6

Profiles

Full Java EE 6

Web ProfileProfile YProfile X

Web Profile

Subset of full platform

For web development

Separate specificationEvolves at its own pace

Other profiles will comeMinimal (Servlet/JSP)

Portal....

JSF2.0Servlet3.0JSP2.2EL2.2JSTL1.2EJB Lite3.1Managed Beans1.0Interceptors1.1JTA1.1JPA2.0Bean Validation 1.0DI1.0CDI1.0

Pruning

Marks some specifications deprecated in next versionMight disappear from Java EE 7

Pruned in Java EE 6Entity CMP 2.x

JAX-RPC

JAX-R

JSR 88 (Java EE Application Deployment)

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

EJB Lite

Subset of EJB 3.1 Local session bean

Injection

Transaction

Interceptors

Security

Part of Web profile

Not includedMessage Driven Beans

EJB Web Service Endpoint

RMI/IIOP Interoperability

Remote interface

EJB 2.x

Timer service

CMP / BMP

New Specs Updated Specs

DI 1.0

CDI 1.0

Managed Beans 1.0

Bean Validation 1.0

JAX-RS 1.1

EJB 3.1

JPA 2.0

Servlet 3.0

JSF 2.0

Interceptors 1.1

Connectors 1.6

JAX-WS 2.2

JSR-109 1.3

JSP 2.2 / EL 2.2

JSR-250 1.1

Managed Bean 1.0 &
Interceptors 1.1

Managed Bean 1.0: What is it?

Managed Beans are container-managed POJOsLightweight component model

Support a small set of basic servicesInjection of a resource (@Resource...)

Life-cycle management (@PostConstruct, @PreDestroy)

Interceptor (@Interceptors, @AroundInvoke)

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Managed Beans 1.0: Example

@ManagedBeanpublic class MyPojo {

@Resource // Resource injection private Datasource ds;

@PostConstruct // Life-cycle private void init() { .... }

public void myMethod() {...}}

Managed Bean vs. EJB and REST

You could see everything as a Managed Bean with extra services

An EJB is a Managed Bean with :Transaction support

Security

Thread safety

A REST service is a Managed Bean withHTTP support

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Interceptors 1.1: What is it?

Address cross-cutting concerns in Java EE

Was part of the EJB 3.0 spec

Now a separate spec shipped with EJB 3.1

Can be uses in EJBs...

as well as ManagedBeans

@AroundInvoke

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Managed Beans 1.0: Example

@ManagedBean@Interceptors(LoggingInterceptor.class)public class MyPojo {

public void myMethod() {...}}

public class LoggingInterceptor {

@AroundInvoke public Object logMethod(InvContext ic) {...}}

Demo: Managed Bean & Interceptor

Create a managed bean IsbnGenerator

Inject the managed bean through @Resource (works only under a container environment)

Use an interceptor for logging

Use appclient container (from GlassFish) to run it

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Dependency Injection
for Java (DI) 1.0 (JSR 330) &

Context and
Dependency Injection (CDI) 1.0
(JSR 299)

Stands for Dependency Injection for Java

Java EE 5 has resource injection@Resource, @PersistenceContext, @EJB

But there is no application level injection in Java EE 5

DI 1.0 introduces @Inject annotation (and others) for application level injection

Spec. leads are Bob Lee (from Google) and Rod Johnson (from SpringSource)

DI 1.0 (JSR 330): What & Why?

Based on java.util.concurrent.Future

For : Result values

System/Application exceptions thrown from target bean

Cancelation requests

Method signature declares return type as Futuree.g. public Future compute(Task t)

Method implementation returns javax.ejb.AsyncResult Concrete helper class for passing result value to container

javax.ejb.AsyncResult implements Future

Constructor takes result value as argument

javax.inject package

@Inject : Identifies injectable constructors, methods, and fields

@Named : String-based qualifier (for EL)

@Qualifier : Identifies qualifier

@Scope : Identifies scope annotations

@Singleton : Instantiates once

DI 1.0 (JSR 330)

Based on java.util.concurrent.Future

For : Result values

System/Application exceptions thrown from target bean

Cancelation requests

Method signature declares return type as Futuree.g. public Future compute(Task t)

Method implementation returns javax.ejb.AsyncResult Concrete helper class for passing result value to container

javax.ejb.AsyncResult implements Future

Constructor takes result value as argument

Used to be called WebBeans

Uses annotations defined in DI 1.0 (JSR-330)

@Inject ShoppingCart cart; Bean discovery and wiringContainer discovers beans and wires everything together automatically

Let you use EJBs directly as JSF backing beans

Every object managed by CDI has a well-defined scope@Dependent, @ConversationalScoped, @RequestScoped, @SessionScoped, @ApplicationScoped,

CDI 1.0 (JSR-299)

Based on java.util.concurrent.Future

For : Result values

System/Application exceptions thrown from target bean

Cancelation requests

Method signature declares return type as Futuree.g. public Future compute(Task t)

Method implementation returns javax.ejb.AsyncResult Concrete helper class for passing result value to container

javax.ejb.AsyncResult implements Future

Constructor takes result value as argument

Injected type is identified byQualifier(s) + Java type

e.g. @Inject @LoggedIn User user;

Qualifier is used to narrow down a particular class when more than one candidate for injection exists

Context management with scopes@ConversationScoped

public class ShoppingCart { }

CDI 1.0 (JSR-299)

Based on java.util.concurrent.Future

For : Result values

System/Application exceptions thrown from target bean

Cancelation requests

Method signature declares return type as Futuree.g. public Future compute(Task t)

Method implementation returns javax.ejb.AsyncResult Concrete helper class for passing result value to container

javax.ejb.AsyncResult implements Future

Constructor takes result value as argument

ItemController Bean and Dependency Injection

import service.CatalogService;@Controller@Scope("session")public class ItemController {

@Inject private CatalogService catalogService ; . . .

Inject Bean

Creates ItemController bean no need to put in .xml

CatalogService injected by type

getItems() method wraps a List of items, returned from the CatalogFacade Stateless Session EJB, in a DataModel.

dataTable, supports data binding to a collection of data objects represented by a DataModel instance, which is the current value of this component itself. The data collection underlying a DataModel instance is modeled as a collection of row objects that can be accessed by a row index. The APIs provide mechanisms to position to a specified row index, and to retrieve an object that represents the data that corresponds to the current row index.

Demo:

How to Check Outglassfish-samples

www.javapassion.com/handsonlabs/javaee6_examples/#Exercise_1

Demo:

DI & CDIwebbeans-guess(Available from glassfish-samples project)

JPA 2.0

JPA 2.0 Features

Richer mappings

Richer JPQL

Pessimistic Locking

Criteria API

Cache API

Many more

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JPA 2.0: Richer Mapping

Supports collection of basic types and embeddablesIn JPA 1.0, only collections of entities were supported

Supports multiple levels of embeddables

Embeddables containing collection of embeddables and basic types

PK can be derived entities

More support for Maps...

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JPA 2.0: Collection of basic types

@EntityPublic class Item {

@ElementCollection private Set tags;}

@EntityPublic class Item {

@ElementCollection @CollectionTable(name="TAGS") private Set tags;}

Mapped by default in ITEM_TAGS

Mapped in TAGS

JPA 2.0: Richer JPQL

Added entity type to support non-polymorphic queries

Allow joins in subquery FROM clause

Added new operatorsINDEX (for ordered lists)

CASE (for case expressions)

more

Added new reserved wordsABS, BOTH, CONCAT, ELSE, END, ESCAPE, LEADING, LENGTH, LOCATE, SET, SIZE, SQRT, SUBSTRING, TRAILING

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Example: JPQL CASE Expression

@Entity public class Employee { @Id Integer empId; String name; Float salary; Integer rating; // ...}

UPDATE Employee eSET e.salary = CASE WHEN e.rating = 1 THEN e.salary * 1.05 WHEN e.rating = 2 THEN e.salary * 1.02 ELSE e.salary * 0.95 END

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JPA 2.0: Standard Properties

In persistence.xml :javax.persistence.jdbc.driver

javax.persistence.jdbc.url

javax.persistence.jdbc.user

javax.persistence.jdbc.password

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JPA 2.0: Locking Enhancements

JPA 1.0 supports only optimist locking

JPA 2.0 adds pessimistic locking

Multiple places to specify lockread and lock

read then lock

read then lock and refresh

public enum LockModeType { OPTIMISTIC, OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC, PESSIMISTIC_FORCE_INCREMENT, NONE}

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Example Scenario

public void applyCharges () { em.getTransaction().begin(); Account acct = em.find (Account.class, acctId); // Do some work to compute charge double balance = acct.getBalance(); if (charge > 0){ acct.setBalance(balance charge); } em.getTransaction().commit();}

source: Mike Keith

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Pessimistic Locking: Example 1

// // Read then lock//public void applyCharges () { em.getTransaction().begin(); Account acct = em.find (Account.class, acctId); // Do some work to compute charge double balance = acct.getBalance(); if (charge > 0){ em.lock(acct, PESSIMISTIC); acct.setBalance(balance charge); } em.getTransaction().commit();}

source: Mike Keith

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Pessimistic Locking: Example 2

// // Read and lock//public void applyCharges () { em.getTransaction().begin(); Account acct = em.find (Account.class, acctId, PESSIMISTIC); // Do some work to compute charge double balance = acct.getBalance(); if (charge > 0){ acct.setBalance(balance charge); } em.getTransaction().commit();}

source: Mike Keith

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Pessimistic Locking: Example 3

// // Read then lock and refresh//public void applyCharges () { em.getTransaction().begin(); Account acct = em.find (Account.class, acctId); // Do some work to compute charge em.refresh(acct, PESSIMISTIC); double balance = acct.getBalance(); if (charge > 0){ acct.setBalance(balance charge); } em.getTransaction().commit();}

source: Mike Keith

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JPA 2.0: Criteria API

Strongly typed criteria API

Object-based query definition objectsrather than string-based

Like JPQL

Uses a metamodel Compile time type checking using GenericsEach entity X has a metamodel class X_

Criteria API operates on the metamodel

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JPA 2.0: Criteria API Example #1

// Retrieve all orders whose lineitems is empty.

// Using Criteria APICriteriaBuilder qb = em.getEntityManagerFactory().getCriteriaBuilder();CriteriaQuery cq = qb.createQuery(Order.class);Root order = cq.from(Order.class);cq.where(qb.isEmpty(order.get(Order_.lineitems))).select(order);

// Using JPQLSELECT oFROM Order oWHERE o.lineItems IS EMPTY

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JPA 2.0: Criteria API Example #2

// Using Criteria APICriteriaBuilder qb = em.getEntityManagerFactory().getCriteriaBuilder();CriteriaQuery q = qb.createQuery(Customer.class);Root customer = q.from(Customer.class);Join order = customer.join(Customer_.orders, JoinType.LEFT);q.where(qb.equal(customer.get(Customer_.status), 1)).select(customer);

// Using JPQLSELECT c FROM Customer c LEFT JOIN c.orders o WHERE c.status = 1

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JPA 2.0: Caching

Supports the use of a second-level cache

Cache APIcontain(Class, PK)

evict(Class, PK), evict(Class)

evictAll()

@Cacheable annotation on entities

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Demo : Book Entity

Servlet 3.0

Ease of DevelopmentThrough annotation

Dynamic registration of Servlets and FiltersDuring runtime

Pluggability (of 3rd-party frameworks/libs)No more tweaking of web.xml is needed

Asynchronous ServletSupport Comet applications

Security enhancements

Servlet 3.0 Features

// web.xml is not needed anymore@WebServlet(urlPatterns=/foo, name=MyServlet, asyncSupported=true)public class SimpleSample extends HttpServlet{ public void doGet( HttpServletRequest req, HttpServletResponse res){ // Some code }}

Ease of Use: Use of Annotation

public class TestServletContextListener implements ServletContextListener {

@Override public void contextInitialized(ServletContextEvent sce) {

ServletContext servletConext = sce.getServletContext(); // Servlets/Filters can be added during runtime ServletRegistration.Dynamic dynamic = servletContext.addServlet( "DynamicServlet", "com.mycom.MyServlet");

dynamic.addMapping("/dynamicServlet"); dynamic.setAsyncSupported(true);

Dynamic Registration of Servlets/Filters

Demo:

Servlet 3.0 Featuers:Annotation, Dynamic Registration

(Available from glassfish-samples project)

Pluggability (of 3rd party Frameworks)

Make it possible to use 3rd-party framework and libraries without configuration in web.xml

A framework is provided as a self-contained jar file

All you have to do use the framework is to place the self-contained jar file under /WEB-INF/lib directory

Pluggability: Modularization of web.xml

No more tweaking of single web.xml

Each framework defines its own web-fragment.xmlDeclare their own controller servlet

Declare listener and filters

Container then collects them all

Overridden by main web.xmlOrder of the frameworks/libs can be specified in the web.xml

A self-contained framework is provided as a jar file and placed under WEB-INF/libweb.xml (optional)

WEB-INF/lib/someframework1.jar

META-INF/web-fragment.xmlWEB-INF/lib/someframework2.jar

META-INF/web-fragment.xml

Pluggability Modularization of web.xml

Pluggability - web-fragment.xml

MyFramework com.mycom.MyFrameworkServlet MyFramework /MyFramework ...

Demo:

Servlet 3.0 Featuers:Pluggabilityabsolute-ordering-web-fragments

(Available from glassfish-samples project)

Asynchronous Servlet

Async. Servlets are for preventing thread starvation in cases such as following in standard (thus portable) fashionWaiting for resources (eg JDBC connection)

Waiting for Comet events (eg Published message in Comet-based Chat application)

Waiting for responses (eg web services)

Better scalability

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Asynch. Servlet: Blocked vs. Asynch. Waiting for Web Services

Blocking

Asynchronous

Thread blockedWS request In parallel

import javax.servlet.*;

Queue usersQueue;
BlockingQueue messageQueue;@WebServlet(urlPatterns = {"/chat"}, asyncSupported = true)
public class ChatServlet extends HttpServlet { doGet(...) {
AsyncContext ac = req.startAsync();
ac.setTimeout(10 * 60 * 1000);
ac.addListener(new AsyncListener() {
public void onComplete(AsyncEvent event) {
usersQueue.remove(ac);
} // deal with more events ...
});
usersQueue.add(ac);
}
...

ChatServlet (1/2)

doPost(...) {
// also deal with system (login) messages
String message = req.getParameter("message");
messageQueue.put(message);
}

init(...) {
while (true) {
String message = messageQueue.take();
for (AsyncContext ac : usersQueue) {
PrintWriter acWriter =
ac.getResponse().getWriter();
acWriter.println(message);
}
}
}}

ChatServlet (2/2)

Demo:

Servlet 3.0 Featuers:Comet using Asynch. API

(Available from glassfish-samples project)

Demo : Add a Servlet

EJB 3.1

Packaging in a war file

Optional Local Interfaces

Singleton

Asynchronous calls

Cron-based Timer Service

Embeddable Container

EJB Lite

EJB 3.1

Based on java.util.concurrent.Future

For : Result values

System/Application exceptions thrown from target bean

Cancelation requests

Method signature declares return type as Futuree.g. public Future compute(Task t)

Method implementation returns javax.ejb.AsyncResult Concrete helper class for passing result value to container

javax.ejb.AsyncResult implements Future

Constructor takes result value as argument

Packaging in a war file

EJB components can be packaged directly inside a web application archive (war file)

Goal is to remove an artificial packaging restrictionNOT to create a new flavor of EJB component

EJB component behavior is independent of packagingOne exception : module-level vs. component-level environment

Full EJB container functionality available

No new restrictions placed on .war Deploy stand-alone OR in an .ear

Demo:

EJB 3.1: SimplifiedPackaging

EJB 3.1: Optional Local Interface

One source file for bean

@Statelesspublic class HelloBean { // No interface

public String sayHello() { return "Hello Brazil!"; } }

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

EJB 3.1: Asynchronous calls

@Statelesspublic class OrderBean {

public void createOrder() { Order order = persistOrder(); sendEmail(order) ; } public Order persistOrder() {...}

@Asynchronous public Future sendEmail(Order order){ ...}}

EJB 3.1: Timer Service

@Statelesspublic class WakeUpBean { @Schedule(dayOfWeek="Mon-Fri", hour="9") void wakeUp() { ... }}

Demo : Add an EJB stateless

EJB 3.1: Singleton

One single instance per application

Share state

@Singleton

Support for container-managed concurrency and bean-managed concurrency@ConcurrencyManagement

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

EJB 3.1: Singleton

@Singletonpublic class CachingBean {

private Map cache;

@PostConstruct void init() { cache = ...; } public Map getCache() { return cache; } public void addToCache(Object key, Object val) { cache.put(key, val); }}

Demo : Add a Singleton EJB

EJB 3.1: Embeddable Container

API allowing to :Initialize a container

Get container ctx

Can run in any Java SE environmentBatch processing

Simplifies testing

Just a jar file in your classpath

Java SETransaction managerSecurity systemMessaging engineEJB 3.1 Embedded containerThis is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

EJB 3.1: Embeddable Container

... public static void main(String[] args){

EJBContainer container = EJBContainer.createEJBContainer();

Context context = container.getContext();

Hello h = (Hello) context.lookup("java:global/classes/HelloEJB"); h.sayHello;

container.close(); }...

Demo : EJB Container Test

JSF 2.0

JSF 2.0

Annotation basedfaces-config.xml is optional

Easy navigation

Page description languageFacelets (preferred)

JSP (still supported)

Templating

Composite components

Ajax support

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

General JSF Architecture

JSF 2.0: Managed Bean Annotation

JSF 1.0 in faces-config.xml

login com.corejsf.Login session

JSF 2.0 faces-config.xml is optional

@ManagedBean @SessionScopedpublic class Login { ... }

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JSF 2.0: Easy Navigation

JSF 1.0 in faces-config.xml

next /next.jsp

JSF 2.0

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JSF 2.0: Facelets

Preferred view handler in JSFAddresses problems of using JSP with JSF

XHTML

Pages are usable from HTML editors

Templating

Composite components

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Demo : Add a JSF page

JSF 2.0: Composite Components

Made up of simpler components

True JSF component

Much easier to build in JSF 2.0 (than in JSF 1.0)Single file, No Java code is needed

NetBeans 6.8 provides Convert to Composite Component wizard

Can attach listeners, validators

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JSF 2.0: Composite Component

Declare a component

Hello #{cc.attrs.who}

Use it

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Demo : Composite Component

JSF 2.0: Ajax Support Using tag

Very easy to use Ajax with JSF components

Partial lifecycle executed for named components

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JSF 2.0: Ajax Support Using JavaScript

Use jsf.js JavaScript library

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Demo: JSF with Ajax

Bean Validation 1.0

Bean Validation 1.0: What is it?

Enable declarative validation in your applications

Constrain Once, Validate Anywhererestriction on a bean, field or property

not null, size between 1 and 7, valid email...

Standard way to validate constraints

Integration with JPA 2.0 & JSF 2.0

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Bean Validation 1.0: Example

public class Address { @NotNull @Size(max=30, message="longer than {max} characters") private String street1; ... @NotNull @Valid private Country country;}

public class Country { @NotNull @Size(max=30) private String name; ...}

Demo : Validation Item/ItemBean

JAX-RS 1.1

JAX-RS 1.1

JAX-RS 1.0 has been released in 2008RESTful Services

POJO and Annotations Based

Maps HTTP verbs (Get, Post, Put, Delete...)

JAX-RS 1.1 Part of Java EE 6

EJB support

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

JAX-RS 1.1: EJB Support

@Path("/users/{userId}")@Statelesspublic class UserResource {

@PersistenceContext EntityManage em;

@GET @Produces("text/xml") public String getUser(@PathParam("userId") String id){

User u = em.find(User.class, id) ... }}

Demo : Add REST service to EJB

Summary & Resources

Summary

Java EE 6 is a standard based next generation enterprise application development and deployment platform

Java EE 6 leverages proven best practice ideas

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Resources

Sun's Java EE homesitehttp://java.sun.com/javaee/

Sang Shin's Advanced Java EE programming online coursewww.javapassion.com/javaee_advanced/

Java EE 6 with GlassFish 3 book written by Antonio Goncalves

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

Acknowledgement

Many slides and demos in this presentation is borrowed from Java EE 6 University session of Devoxx 2009 authored by Antonio Goncalves and Alexis Moussine-Pouchkine (with their permission)

Many demos are from glassfish-sample project

This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective.

Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum.

Deployment descriptors are still present if you or your company needs them.

JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.

THANK YOU!

Carol McDonald

Sun Microsystems, Inc.

Page

Click to edit the title text format

Click to edit the outline text formatSecond Outline Levelx

Click to edit the notes format

Page

Click to edit the title text format

Presenters NamePresenters TitlePresenters Company

Click to edit the notes format

Page

Click to edit the title text format

Presenter's NamePresenters TitlePresenters Company

Click to edit the notes format

Exact File Name

1/13/10

Page