Java EE 6 Component Model Explained

91
<Insert Picture Here> Java EE Component Model Explained Shreedhar Ganapathy, Java EE & GlassFish Guy Oracle Corporation Inc.

Transcript of Java EE 6 Component Model Explained

Page 1: Java EE 6 Component Model Explained

<Insert Picture Here>

Java EE Component Model Explained

Shreedhar Ganapathy, Java EE & GlassFish GuyOracle Corporation Inc.

Page 2: Java EE 6 Component Model Explained

2

The following/preceding 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 6 Component Model Explained

3

JavaTM Enterprise Edition

How We Evolved

Page 4: Java EE 6 Component Model Explained

4

JPEProject

J2EE 1.2Servlet, JSP,

EJB, JMSRMI/IIOP

J2EE 1.3CMP,

ConnectorArchitecture

J2EE 1.4Web Services, Management, Deployment, Async. Connector

Java EE 5Ease of DevelopmentAnnotationsEJB 3.0Persistence APINew and Updated Web Services

Robustness

Web Services

Enterprise Java

Platform

Java EE 6PruningExtensibilityProfilesEase-of-devEJB LiteRESTful WSCDI

Java EE 6Web Profile

Ease ofDevelopment

FlexiblePast, Present, Future

ManagedBean 1.0

May 98 Dec 99 Sep 01 Nov 03 May 06 Dec 09 H2 CY12 10 specs 13 specs 20 specs 23 specs 28 specs ?? specs

Java EE 7Multi-tenancyElasticityJSONHTML 5Web Sockets. . .

Cloud

Page 5: Java EE 6 Component Model Explained

5

Compatible Java EE 5 Impl

http://java.sun.com/javaee/overview/compatibility-javaee5.jsp

Page 6: Java EE 6 Component Model Explained

6

Compatible Java EE 6 Impls

Today:

Announced:

Web Profile Only

Page 7: Java EE 6 Component Model Explained

7

What's New in Java EE 6

Page 8: Java EE 6 Component Model Explained

8

Java EE 6 Specifications

• The Platform• Java EE 6 Web Profile 1.0• Managed Beans 1.0

Page 9: Java EE 6 Component Model Explained

9

Java EE 6 SpecificationsNew

• Contexts and Dependency Injection for Java EE (JSR 299)

• Bean Validation 1.0 (JSR 303)• Java API for RESTful Web Services (JSR 311)• Dependency Injection for Java (JSR 330)

Page 10: Java EE 6 Component Model Explained

10

Java EE 6 SpecificationsExtreme Makeover

• Java Server Faces 2.0 (JSR 314)• Java Servlets 3.0 (JSR 315)• Java Persistence 2.0 (JSR 317)• Enterprise Java Beans 3.1 & Interceptors 1.1

(JSR 318)• Java EE Connector Architecture 1.6 (JSR 322)

Page 11: Java EE 6 Component Model Explained

11

Java EE 6 SpecificationsUpdates

• Java API for XML-based Web Services 2.2 (JSR 224)• Java API for XML Binding 2.2 (JSR 222)• Web Services Metadata MR3 (JSR 181)• JSP 2.2/EL 2.2 (JSR 245)• Web Services for Java EE 1.3 (JSR 109)• Common Annotations 1.1 (JSR 250)• Java Authorization Contract for Containers 1.3 (JSR 115)• Java Authentication Service Provider Interface for

Containers 1.0 (JSR 196)

Page 12: Java EE 6 Component Model Explained

12

Java EE 6 SpecificationsAs is

• JDBC 4.0 API• Java Naming and Directory Interface 1.2• Java Message Service 1.1• Java Transaction API 1.1• Java Transaction Service 1.0• JavaMail API Specification 1.4• JavaBeans Activation Framework 1.1• Java API for XML Processing 1.3• Java API for XML-based RPC 1.1• SOAP with Attachments API for Java 1.3• Java API for XML Registries 1.0• Java EE Management Specification 1.1 (JSR 77)• Java EE Deployment Specification 1.2 (JSR 88)• Java Management Extensions 1.2• Java Authentication and Authorization Service 1.0• Debugging Support for Other Languages (JSR 45)• Standard Tag Library for JSP 1.2 (JSR 52)• Streaming API for XML 1.0 (JSR 173)

Page 13: Java EE 6 Component Model Explained

13

http://blog.eisele.net/2010/12/who-is-afraid-of-java-ee-6-get-rid-of.html

Page 14: Java EE 6 Component Model Explained

14

Java EE 6 Web Profile 1.0

Servlets 3.0

JSP 2.2

JSF 2.0

EJB 3.1 Lite

JTA 1.1ManagedBeans 1.0

JPA 2.0

CDI 1.0

BeanValidation1.0

Interceptors1.1

JAX-WS

JAX-RS

JAXB

EJB 3.1

JASPIC

JDBC

JNDI

JMS

JAXP

JAX-RPC . . .

SAAJ

JACC

JavaMail

StAX

New Updated Contributed by RedHat

Page 15: Java EE 6 Component Model Explained

15

Java EE 6 – New Concepts

• Pruning the unused • Profiles

• Web Profile Support

• EJB Lite in Web Tier

Lightweight & Flexible

Page 16: Java EE 6 Component Model Explained

16

Ease-Of-Use Programming Model Improvements

• Managed Beans• Context and Dependency Injection (CDI)• Servlet 3.0 annotations support• EJB 3.1 - Singletons, Stateless and Stateful Bean

Annotations, Timer Service, Portable JNDI Name • Bean Validation• JPA 2.0• JSF 2.0• JAX-RS

Java EE 6 – New Concepts

Page 17: Java EE 6 Component Model Explained

17

Extensible

• Servlet 3.0 Pluggability• CDI Extenions

Java EE 6 – New Concepts

Page 18: Java EE 6 Component Model Explained

18

• Pruned today, means• Optional in the next Java EE release• Deleted in the subsequent releases

• Technologies marked as optional for EE 6• EJB 2.x Entity Beans, • JAX-RPC, • JAXR, • JSR 88

• Might go away in Java EE 7

Lightweight & Flexible

Pruning

Page 19: Java EE 6 Component Model Explained

19

Lightweight & Flexible Profiles Support

Java EE 6 Full Platform

FutureProfile X

Java EE 6 Web Profile

Page 20: Java EE 6 Component Model Explained

20

• Subset of full platform • For web development

• Packages in a war • Separate specification• Other Profiles Can Come

• Minimal (Servlet/JSP) • Portal, etc.

Lightweight & Flexible

Web Profile SupportJSF 2.0

Servlet 3.0

JSP 2.2

EL 2.2

JSTL 1.2

EJB Lite 3.1

Managed Beans 1.0

Interceptors 1.1

JTA 1.1

JPA 2.0

Bean Validation 1.0

Java CDI 1.0

@Inject 1.0

Page 21: Java EE 6 Component Model Explained

21

• Subset of EJB 3.1 API

• Part of Web Profile• Web Apps can package

Local Session Beans in WAR

• Session Bean Programming Model• Stateful, Stateless,

Singleton

Lightweight & Flexible EJB Lite

• Descriptor OK But Optional

• Annotation-driven• @Schedule• @Path• @Inject . . .• No Interface EJBs

• Transactions (CMT/BMT)• Interceptors• Declarative Security

Page 22: Java EE 6 Component Model Explained

22

Java EE 6 Core Programming Model

Page 23: Java EE 6 Component Model Explained

23

Programming Model Improvements

• Separate spec shipped with Java EE 6• Managed Beans are container- managed

POJOs• Support a small set of basic services

• Injection (@Resource, @Inject)• Life-cycle (@PostConstruct, @PreDestroy)• Interceptor (@Interceptor, @AroundInvoke)

• Lightweight component model• Foundation for other component types

Managed Beans

Page 24: Java EE 6 Component Model Explained

24

Managed Beans 1.0

@javax.annotation.ManagedBean

public class MyPojo {

@Resource

private Datasource ds;

@PostConstruct

private void init() {

....

}

public void myMethod() {...}

}

JSR 250 Commons annotations

Page 25: Java EE 6 Component Model Explained

25

EJBs & REST Services are Managed Beans

• All Managed Beans core services available in EJBs, and REST Services

• EJB component model extends managed beans with • Transaction support, • Security, • Multi-threading

• REST Service is a Managed Bean with HTTP support

Page 26: Java EE 6 Component Model Explained

26

EJBs and REST Service Managed Beans

New capabilities engaged on demand via annotations

• @Stateful, @Stateless, @Singleton• @TransactionAttribute • @RolesAllowed, @DenyAll, @PermitAll• @Remote • @WebService• @Path

Page 27: Java EE 6 Component Model Explained

27

Incremental Programming Model• Start with POJOs (@ManagedBean) • Use all the basic services • Turn them into session beans as needed • Take advantage of new capabilities • No changes to (local) clients@ManagedBean

public class A {

@Resource DataSource myDB; ....

}

@Stateful

public class A {

@Resource DataSource myDB; ...

}

Page 28: Java EE 6 Component Model Explained

28

Contexts & Dependency InjectionJSR 299

• Standards-based Dependency Injection• Type-safe – Builds on @Inject API• Context/Scope management• Strong Typing, Loose Coupling• Includes ELResolver

@Inject @LoggedIn User user

RequestInjection

What ?(Type)

Which one ?(Qualifier)

@Inject @LoggedIn User

Page 29: Java EE 6 Component Model Explained

29

CDI

• Qualifiers• Events• Stereotypes• Interceptors• Decorators• Alternatives• . . .

Page 30: Java EE 6 Component Model Explained

30

Contexts 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)Qualifiers describe qualities/characteristics/identity.

Page 31: Java EE 6 Component Model Explained

31

CDI Extensibility

• Drag-and-drop model • Bean archives can contain reusable sets of beans• Extensions can process any annotated types and

define beans on-the-fly• Clients only need to use @Inject• No XYZFactoryManagerFactory horrors!

@Inject @Reliable PayBy(CREDIT_CARD) PaymentProcessor;

Page 32: Java EE 6 Component Model Explained

32

Servlet 3.0• Annotations based programming model

• @WebServlet – Define a Servlet

• @WebFilter – Define a Filter

• @WebListener – Define a Listener

• @WebInitParam – Define Init Param

• @MultipartConfig – Define file upload properties

• @ServletSecurity – Define security constraints

• Optional web.xml

Page 33: Java EE 6 Component Model Explained

33

Servlet 3.0 Pluggability• Drag-and-drop model• Web frameworks as fully configured libraries (Only jars

in WEB-INF/lib considered as fragment)• META-INF/web-fragment.xml• Use <web-fragment> instead of <web-app>

• Annotations and web fragments are merged following a configurable order

• Overridden by main web.xml • Extensions can register listeners, servlets, filters

dynamically• Extensions can discover and process annotated

classes@HandlesTypes(WebService.class)

public class MyWebServiceExtension implements ServletContanerInitializer { ... }

Page 34: Java EE 6 Component Model Explained

34

<web-fragment> <filter> <filter-name>wicket.helloworld</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> <init-param> <param-name>applicationClassName</param-name> <param-value>...</param-value> </init-param> </filter>

<filter-mapping> <filter-name>wicket.helloworld</filter-name> <url-pattern>/*</url-pattern> </filter-mapping></web-fragment>

Servlet 3.0 – Web Fragment Sample

Page 35: Java EE 6 Component Model Explained

35

Servlet 2.5 Samplepublic class MyServlet extends HttpServlet {

public void doGet (HttpServletRequest req,

HttpServletResponse res) {

....

}

}

Deployment descriptor (web.xml)

<web-app>

<servlet>

<servlet-name>MyServlet</servlet-name> <servlet-class>samples.MyServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>MyServlet</servlet-name>

<url-pattern>/MyApp</url-pattern>

</servlet-mapping>

...

</web-app>

Page 36: Java EE 6 Component Model Explained

36

Servlet 3.0 Sample

@WebServlet(urlPatterns={"/MyApp"}) public class MyServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res){ .... }}

Same for @WebFilter and @WebListener

web.xml is optional

Page 37: Java EE 6 Component Model Explained

37

Asynchronous Support

• Servlets block waiting for a response• Now they can start an asynchronous task...• then, use a container callback ... that invokes

the servlet to end processing• Better scalability• New APIs for ServletRequest and Response• Does not require NIO

Page 38: Java EE 6 Component Model Explained

38

Why Asynchronous Servlets?

• Not for Async IO• Requests mostly small (single packet)• Hard to asynchronously produce large

responses• Async IO support waiting for NIO2

• Async Servlets are for:• Waiting for resources (eg JDBC connection)• Waiting for events (eg Chat)• Waiting for responses (eg web services)

Page 39: Java EE 6 Component Model Explained

39

Blocking Waiting Consumes Resources

• Web Application using remote web services• Handling 1000 requests / sec• 50% requests call remote web service• 500 threads in container thread pool

• If remote web service is slow (1000ms)• Thread starvation in 1 second!• 50% of requests use all 500 threads

Page 40: Java EE 6 Component Model Explained

40

WebServlet Async Code Sample

@WebServlet(urlPatterns=“/myApp”, name=”MyServlet”, asyncSupported=true)

public class SimpleSample extends HttpServlet

{

public void doGet(HttpServletRequest req,HttpServletResponse res)

{

}

}

Page 41: Java EE 6 Component Model Explained

41

Asynchronous APIEnable asynchronous support

• Configured in• web.xml: <async-supported>true</async-supported>

• With annotation: @WebServlet(asyncSupported=true)

• Programmatic: registration.setAsyncSupported(true)

Page 42: Java EE 6 Component Model Explained

42

EJB 3.1

• Packaging in a war • Interceptors• Optional Local Interfaces • Singleton • Asynchronous calls • Cron-based Timer Service • Embeddable Container • EJB Lite

Page 43: Java EE 6 Component Model Explained

43

EJB 3.1 (JSR 318)Package & Deploy in a WAR

myApp.ear

web.war

WEB-INF/web.xmlWEB-INF/classes com.sun.FooServlet com.sun.TickTock

beans.jar

com.sun.FooBeancom.sun.FooHelper

myApp.war

WEB-INF/classes com.sun.FooServlet com.sun.TickTock com.sun.FooBean com.sun.FooHelper

web.xml ?

Java EE 5 Java EE 6

http://blogs.sun.com/arungupta/entry/totd_95_ejb_3_1

Page 44: Java EE 6 Component Model Explained

44

Session Bean with Local Business Interface in Java EE 5

Page 45: Java EE 6 Component Model Explained

45

Optional Local Business Interface

• Sometimes separate local interface isn't needed• Particularly for fine-grained EJBs whose callers are co-

located

• Better to completely remove this from developer's view• Result : “no-interface” Local view

• Just a bean class • All public methods exposed to client• Client programming model almost identical to local business

interface

• Client does not call new() on bean class

Page 46: Java EE 6 Component Model Explained

46

public class MySessionBean {

public void setupResources() { // setup your resources }

public void cleanupResources() { // collect them back here }

public String sayHello(String name) { return "Hello " + name;

}

}

EJB 3.1 – Sample Session Bean with No-Interface View, and Client

@EJB / @InjectMySessionBean bean;

...

bean.sayHello(“Bob”);

@Stateless

@PostConstruct

@PreDestroy

Page 47: Java EE 6 Component Model Explained

47

Intercepters 1.1

• Intercepters were part of EJB 3.0 Spec • Pulled out to address broad EE 6 component needs• Now a separate spec shipped with EJB 3.1• Use with EJBs and any ManagedBean• Intercepters invoked through @AroundInvoke for

ManagedBeans and for Timers through @AroundTimeout

Page 48: Java EE 6 Component Model Explained

48

Intercepters 1.1

• With CDI, you can use interceptor bindings @Logged

@ManagedBean

public class A { ... }

where @InterceptorBinding

public @interface Logged { ... }

and @Interceptor @Logged

public class Logger {

@AroundInvoke void do(InvocationContext c){...}

}

Page 49: Java EE 6 Component Model Explained

49

Portable Global JNDI Name

• Prior to EJB 3.1, each vendor chose a vendor specific name to publish EJB references in JNDI• Client code had to be modified when deployed on other

vendor product

• With EJB3.1, each vendor is required to publish session beans with spec mandated names

Page 50: Java EE 6 Component Model Explained

50

Portable Global JNDI Names

EJB 3.1 mandates that each session bean is published in JNDI with the following names

• Globally unique name java:global[/<app-name>]/<module-name>/<ejb-name>

• Unique name within same application java:app/<module-name>/<ejb-name>

• Unique name within defining module java:module/<ejb-name>

Page 51: Java EE 6 Component Model Explained

51

Portable JNDI Name – No-Interface Session Bean

@Statelesspublic class HelloBean { public String sayHello(String msg) { return “Hello “ + msg; }}

If deployed as hello.jar, JNDI entries are: java:global/hello/HelloBean java:app/hello/HelloBean java:module/HelloBean

Page 52: Java EE 6 Component Model Explained

52

EJB Singletons

• New session bean component type• Provides easy sharing of state within application• Designed for concurrent access • One bean instance per bean type per VM

• Lots in common with stateless / stateful EJBs• Provides Local, Remote, Web Service client view• Supports CMT / BMT • Same container services are available

• resource managers, timer service, method authorization, etc.

Page 53: Java EE 6 Component Model Explained

53

Simple Singleton

@Singletonpublic class SharedBean { private SharedData data = new SharedData(); public int getIntData() { return data.getIntValue(); } public void setIntValue(int value { data.setIntValue(value); }}

Page 54: Java EE 6 Component Model Explained

54

Singleton Client

@Statelesspublic class FooBean { @EJB // Inject Singleton reference private SharedBean shared;

public void foo() { int value = shared.getIntValue(); ... }}

Page 55: Java EE 6 Component Model Explained

55

Asynchronous Session Bean Invocations

• Async processing in JavaEE 5 apps• JavaEE apps resorted to JMS / MDBs • Must know JMS APIs and setup JMS Queue etc.

• EJB 3.1 makes it very easy • Annotate your method with @Asynchronous

• Control returns to the client before actual method invocation• Persistent delivery guarantees are not required by spec

@Stateless

public class DocBean {

@Asynchronous

public void processDoc(

Document d, String toType){

}

}

Asyc Client@EJB DocBean docBean; Document d1 = new Document(...);Document d2 = new Document(...);

docBean.processDoc(d1, “pdf”); docBean.processDoc(d2, “text”);

Page 56: Java EE 6 Component Model Explained

56

EJB Timers – Calendar Based Timouts

Problem• EJB Timer to expire at 5pm on the 14th and one day

before the last day of the month (“payroll” application)

Solution• Cron-like semantics with improved syntax • Named attributes • Relative to optionally specifi ed time zone • Can be created programmatically or automatically

Page 57: Java EE 6 Component Model Explained

57

Automatic Timer Creation

@Stateless

public class PayrollBean {

@Schedules ({

@Schedule(hour=”17”,dayOfMonth=”14, -1”),

@Schedule(hour=”8”,dayOfMonth=”1st Mon”, month=”Jan, Apr, Jul, Oct”)

})

void sendPayrollStatements() {

...

}

}

Page 58: Java EE 6 Component Model Explained

58

Embeddable API

• Portable API for running EJB components in same process as client code

• Same component behavior / life cycle as server-side• CMT/BMT, injection, threading guarantees, etc.

• “Single Application” model• Only required to support 3.1 “Lite” API

• Vendors can optionally support additional functionality

Page 59: Java EE 6 Component Model Explained

59

Embeddable API Sample

public class BankTester {

public static void main(String[] args) {

EJBContainer container =

EJBContainer.createEJBContainer();

// Acquire Local EJB reference

Bank bank = (Bank)

container.getContext().

lookup(“java:global/bank/BankBean”);

double balance = bank.deposit(100.00);

...

container.close();

}

}

Page 60: Java EE 6 Component Model Explained

60

EJB 3.1EJB 3.1 Lite – Feature Comparison

Page 61: Java EE 6 Component Model Explained

61

JPA 2.0

• Evolves separately from EJB now• JSR 317

• Richer mappings • Richer JPQL • Pessimistic Locking • Criteria API • Cache API

Page 62: Java EE 6 Component Model Explained

62

Richer Mapping

• Supports collection of embeddables and basic types

• Supports multiple levels of embeddables• Embeddables containing collection of

embeddables and basic types• PK can be derived entities • More support for Maps

Page 63: Java EE 6 Component Model Explained

63

Java Persistence API 2 (JSR 317)

•Improved O/R mapping•Type-safe Criteria API•Expanded and Richer JPQL•2nd-level Cache•New locking modes

•PESSIMISTIC_READ – grab shared lock•PESSIMISTIC_WRITE – grab exclusive lock•PESSIMISTIC_FORCE_INCREMENT – update version

•Standard configuration options•javax.persistence.jdbc.[driver | url | user | password]

Page 64: Java EE 6 Component Model Explained

64

Java Server Faces 2.0 (JSR 314)

• Facelets as “templating language” for the page• Custom components much easier to develop

• Integrated Ajax• “faces-config.xml” optional in common cases• Default navigation rules• Much more …

• Runs on Servlet 2.5+• Bookmarkable URLs• Conditional navigation• ...

Page 65: Java EE 6 Component Model Explained

65

Bean Validation (JSR 303)

• Tier-independent mechanism to define constraints for data validation• Represented by annotations• javax.validation.* package

• Integrated with JSF and JPA• JSF: f:validateRequired, f:validateRegexp• JPA: pre-persist, pre-update, and pre-remove

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

• Fully Extensible• @Email String recipient;

Page 66: Java EE 6 Component Model Explained

66

JAX-RS 1.1 (JSR 311)

• Java API for building RESTful Web Services• POJO based• Annotation-driven• Server-side API• HTTP-centric

Page 67: Java EE 6 Component Model Explained

67

JAX-RS 1.1Code Sample - Simple

public class PersonResource {

public List<Person> getPersons() { return personList; }

public Person getPerson( int id) { return getPersons().get(id); }}

@Path("helloworld")@Produces("text/plain")

@Context UriInfo ui;

@GET

@GET @Path("{id}") @PathParam("id")

Page 68: Java EE 6 Component Model Explained

68

IDE Support for Java EE 6

Page 69: Java EE 6 Component Model Explained

69

9 Reasons why Java EE 6 will save $$

• Prototyping (multiple IDEs)• Development (~30MB, incremental deployment, ...)• Production (Variety, Start small/then scale)• Support (Pick the best one)• Training (“Only” Java EE 6 APIs)• Portability (Backwards compatibility)• Adoption (Growing)• Freedom of choice (Multiple vendors)• Plan B (Similar component models)

http://www.adam-bien.com/roller/abien/entry/8_reasons_why_java_ee

Page 70: Java EE 6 Component Model Explained

70

From the real users ...Developers can concentrateon business logic, Java EE 6 is providing a standard for the infrastructure.

Jigsaw puzzle, Modular, standard, less xml, easy, easy, have I said easy?

Higher integrated specs,simple and annotation driven,single-classloader WARs,next level of industry standard

Standards compliance, vendor independence, milliseconds and kilobyte deployment

http://blogs.sun.com/arungupta/tags/community+feedback

Faster development, less frameworks, less complexity, more great code shipped

Not your fat grandfather's enterprise Java anymore, enterprise Java renaissance

Definite excuse to avoid Spring forever

Simplified Java Development, Focus on building great products

Page 71: Java EE 6 Component Model Explained

71

In selecting an application server our main goal was to avoid the framework explosion that happens when you use a "custom" Enterprise stack like Tomcat + Spring + Hibernate + Myfaces +... Java EE 6 had 80% of what we needed out of the box: strong persistence support ( JPA ), inversion of control ( CDI ), and a lightweight component model ( EJB 3.1 )

Avoid “framework explosion”

http://blogs.sun.com/stories/entry/egesa_engineering_avoids_framework_explosion

Page 72: Java EE 6 Component Model Explained

72

What does Java EE offer to Cloud ?

● Containers● Injectable services● Scale to large clusters● Security model● . . .

Page 73: Java EE 6 Component Model Explained

73

Java EE 7 : JSR 342

• Theme: Cloud• More easily operate on private or public clouds• Deliver functionality as a service with support for

features such as multi-tenancy and elasticity• Technology refresh: JMS 2.0, CDI 1.1, ...• Latest web standards: HTML 5 and Web Sockets• Possible JSRs inclusion

• Concurrency Utilities for Java EE (JSR 236)• JCache (JSR 107)

• New JSRs: Web Sockets, Java JSON API• Modularity and Versioning

NEW

Page 74: Java EE 6 Component Model Explained

74

What is GlassFish ?

• A community• Users, Partners, Testers, Developers, ...• Started in 2005 on java.net

• Application Server• Open Source (CDDL & GPL v2)• Basis for Java EE Reference Implementation

Page 75: Java EE 6 Component Model Explained

Distribution License Features

GlassFish Server Open Source Edition 3.1Web Profile

CDDL & GPLv2

• Java EE 6 compatibility• Web Profile support• In-memory replication / clustering• Centralized Administration

GlassFish Open Source Edition 3.1

CDDL & GPLv2

• Java EE 6 compatibility• Full Java EE distribution• In-memory replication / clustering• Centralized Administration

Oracle GlassFish Server 3.1Web Profile Commercial

• Adds• Oracle GlassFish Server Control• Patches, support, knowledge base

Oracle GlassFish Server 3.1 Commercial

• Adds• Oracle GlassFish Server Control• Patches, support, knowledge base

GlassFish Server Distributions

Page 76: Java EE 6 Component Model Explained

76

References

• oracle.com/javaee• glassfish.org• oracle.com/goto/glassfish• blogs.sun.com/theaquarium• youtube.com/GlassFishVideos• Follow @glassfish

Page 77: Java EE 6 Component Model Explained

77

Appendix

Page 78: Java EE 6 Component Model Explained

78

Java EE 7 Schedule

• March 2011 Early EG Formed• Q3 2011 Early Draft• Q1 2012 Public Draft• Q3 2012 Final Release

NEW

Page 79: Java EE 6 Component Model Explained

79

Java EE 7 JSR Soup

• Java Persistence API 2.1 – JSR 338• JAX-RS 2.0 – JSR 339• Servlets 3.1 – JSR 340• Expression Language 3.0 – JSR 341• Java EE 7 – JSR 342 • Java Message Service 2.0 – JSR 343• Java Server Faces 2.2 – JSR 344• EJB 3.2 – JSR 345• CDI 1.1 – JSR 346• JCache – JSR 107

NEW

Page 80: Java EE 6 Component Model Explained

80

JPA 2.1 (JSR 338)http://jcp.org/en/jsr/detail?id=338http://jpa-spec.java.net

● Multi-tenancy● Support for stored procedures, vendor function● Update and Delete Criteria queries, JPQL ↔

Criteria● Query by Example● Support for schema generation● Persistence Context synchronization control● Dynamic definition of PU● Additional event listeners

NEW

Page 81: Java EE 6 Component Model Explained

81

JAX-RS 2.0 (JSR 339)http://jcp.org/en/jsr/detail?id=339http://jax-rs-spec.java.net

● Client API● Low level using Builder pattern, Higher-level

● Hypermedia● MVC Pattern

● Resource controllers, Pluggable viewing technology● Bean Validation

● Form or Query parameter validation● Closer integration with @Inject, etc.● Server-side asynchronous request processing● Server-side content negotiation

NEW

Page 82: Java EE 6 Component Model Explained

82

Servlets 3.1 (JSR 340)http://jcp.org/en/jsr/detail?id=340http://servlet-spec.java.net

• Cloud support• Multi-tenancy

• Security / Session state / Resources isolation

• Asynchronous IO based on NIO2• Simplified Asynchronous Servlets• Utilize Java EE concurrency utilities• Enable support for Web Sockets

NEW

Page 83: Java EE 6 Component Model Explained

83

Expression Language 3.0 (JSR 341)http://jcp.org/en/jsr/detail?id=341http://el-spec.java.net

• A JSR by itself• Make EL easier to use outside EE container

• Simplified to use in Java SE

• EL Context is split into Parsing and Evaluation context

• Explicit coercion rules using API• Criteria-based selection from Collection• Operators: ==, concat, sizeof• CDI events for expression evaluation

NEW

Page 84: Java EE 6 Component Model Explained

84

JMS 2.0 (JSR 343)http://jcp.org/en/jsr/detail?id=343http://jms-spec.java.net

• Long overdue – after 9 years• Modest scope, major extensions

deferred to a subsequent revision• Ease-of-development• Clarification of relationship with other

Java EE specs• New mandatory API for pluggable JMS

provider

NEW

Page 85: Java EE 6 Component Model Explained

85

JSF 2.2 (JSR 344)http://jcp.org/en/jsr/detail?id=344http://jsf-spec.java.net.

• Ease of development• cc:interface is optional• JSF lifecycle is CDI aware• Runtime configuration options change

• Support implementation of Portlet Bridge 2.0• Support for HTML5 features

• Forms, Heading/Section content model, ...

• New components like FileUpload and BackButton

NEW

Page 86: Java EE 6 Component Model Explained

86

EJB 3.2 (JSR 345)http://jcp.org/en/jsr/detail?id=345

• Enablement for use in cloud• Factorization of the EJB technology

• Interceptors was the first example• Container-managed transactions as target

• Alignment with other specifications• Mark “pruned” technologies as optional

• EJB 1.x and 2.x entity beans• Web service invocation using JAX-RPC

NEW

Page 87: Java EE 6 Component Model Explained

87

CDI 1.1 (JSR 346)http://www.jcp.org/en/jsr/proposalDetails?id=346

• Global ordering of interceptors and decorators

• API for managing built-in contexts• Embedded mode to startup outside Java

EE container• Send Servlet events as CDI events

NEW

Page 88: Java EE 6 Component Model Explained

88

Bean Validation 1.1 (JSR TBD)http://in.relation.to/Bloggers/JSRBeanValidation11WhatToPutIn

• Integration with other specs• JAX-RS: Validate parameters on HTTP calls• JAXB: convert into XML schema descriptor• JPA: DDL generation

• Method level validation

• @Valid and group propagation• Apply constraints on element collection

public void processOrder(@Valid Order order, @Min(0) @Max(30) int retry) {}

NEW

Page 89: Java EE 6 Component Model Explained

89

Data Grids (JSR 347)http://jcp.org/en/jsr/detail?id=347

• Accessing, storing, managing data in a distributed data grid

• Build and extend JSR 107 (JCache)• Map-like API to access a Cache• Spooling in-memory data to persistent storage• Register event listeners

• Eviction, replication and distribution of data• Transactions• Async and non-blocking API to access data•

NEW

Page 90: Java EE 6 Component Model Explained

90

Transparency Checklisthttp://jcp.org/en/resources/transparency

• EG members names• EG business reported on publicly

readable alias• Schedule is public, current and updated

regularly• Public can read/write to a wiki• Discussion board on jcp.org• Public read-only issue tracker

NEW

Page 91: Java EE 6 Component Model Explained

<Insert Picture Here>

Java EE 6 Core Programming Model Explained

Shreedhar Ganapathy, Java EE & GlassFish GuyOracle Corporation Inc.