Javaee6 Overview
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Javaee6 Overview

on

  • 4,066 views

 

Statistics

Views

Total Views
4,066
Views on SlideShare
3,903
Embed Views
163

Actions

Likes
7
Downloads
239
Comments
1

7 Embeds 163

http://owen.com 73
http://ibmadmin.wordpress.com 64
http://www.slideshare.net 8
http://localhost 8
http://www.lifeyun.com 6
http://sysdecom-projects.com 3
http://www.lmodules.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • good
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • Based on java.util.concurrent.Future For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future e.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
  • Based on java.util.concurrent.Future For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future e.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
  • Based on java.util.concurrent.Future For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future e.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
  • Based on java.util.concurrent.Future For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future e.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
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • Based on java.util.concurrent.Future For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future e.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
  • Goal is to remove an artificial packaging restriction NOT to create a new flavor of EJB component EJB component behavior is independent of packaging One 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
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.

Javaee6 Overview Presentation Transcript

  • 1. Carol McDonald Java EE 6: The Next Generation Enterprise Application Platform
  • 2. Topics
    • Java EE 6 themes
      • Right-sizing, Extensibility, Ease of development
    • Java EE 6 Technologies
      • Managed Beans & Interceptors
      • 3. Bean validation
      • 4. DI (JSR-330) and CDI (JSR-299)
      • 5. JPA 2.0
      • 6. Servlet 3.0
      • 7. EJB 3.1
      • 8. JSF 2.0
      • 9. JAX-RS 1.1
  • 10. JAVA EE 6 FINAL RELEASE DECEMBER 10, 2009
  • 11. Java EE 6 Themes
  • 12. A brief history May 1998 Project JPE Dec 1999 10 specs J2EE 1.2 Enterprise Application Servlet JSP EJB JMS RMI/IIOP Sept 2001 13 specs J2EE 1.3 Robust Scalable CMP JCA Nov 2003 20 specs J2EE 1.4 Web Services WS Management Deployment May 2006 23 specs Java EE 5 Ease of development Annotations EJB 3 JPA 1.0 WS-* JSF Q4 2009 28 specs Java EE 6 Right-sizing EJB 3.1 JPA 2.0 Servlet 3.0 JSF 2.0 JAX-RS 1.1 JCDI 1.0 @Inject Bean Validat° Web Profile Managed Bean
  • 13.
    • Right-sizing
      • Profiles & Pruning
      • 14. Use only what you need
      • 15. Web profile, EJB Lite
    • Extensibility (Pluggability)
      • Use 3rd-party frameworks or libraries without extra configuration
    • Ease of development
      • Default over configuration
      • 16. Dependency Injection (DI)
    Major Themes of Java EE 6
  • 17. Profiles
  • 18. Web Profile
    • Subset of full platform
    • 19. For web development
    • 20. Separate specification
      • Evolves at its own pace
    • Other profiles will come
      • Minimal (Servlet/JSP)
      • 21. Portal....
    JSF 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 DI 1.0 CDI 1.0
  • 22. Pruning
    • Marks some specifications “deprecated” in next version
      • Might disappear from Java EE 7
    • Pruned in Java EE 6
      • Entity CMP 2.x
      • 23. JAX-RPC
      • 24. JAX-R
      • 25. JSR 88 (Java EE Application Deployment)
  • 26. EJB Lite
    • Subset of EJB 3.1
      • Local session bean
      • 27. Injection
      • 28. Transaction
      • 29. Interceptors
      • 30. Security
    • Part of Web profile
    • Not included
      • Message Driven Beans
      • 31. EJB Web Service Endpoint
      • 32. RMI/IIOP Interoperability
      • 33. Remote interface
      • 34. EJB 2.x
      • 35. Timer service
      • 36. CMP / BMP
  • 37. New Specs Updated Specs
    • DI 1.0
    • 38. CDI 1.0
    • 39. Managed Beans 1.0
    • 40. Bean Validation 1.0
    • 41. JAX-RS 1.1
    • EJB 3.1
    • 42. JPA 2.0
    • 43. Servlet 3.0
    • 44. JSF 2.0
    • 45. Interceptors 1.1
    • 46. Connectors 1.6
    • 47. JAX-WS 2.2
    • 48. JSR-109 1.3
    • 49. JSP 2.2 / EL 2.2
    • 50. JSR-250 1.1
  • 51. Managed Bean 1.0 & Interceptors 1.1
  • 52. Managed Bean 1.0: What is it?
    • Managed Beans are container-managed POJOs
      • Lightweight component model
    • Support a small set of basic services
      • Injection of a resource (@Resource...)
      • 53. Life-cycle management (@PostConstruct, @PreDestroy)
      • 54. Interceptor (@Interceptors, @AroundInvoke)
  • 55. Managed Beans 1.0: Example @ManagedBean public class MyPojo { @Resource // Resource injection private Datasource ds; @PostConstruct // Life-cycle private void init() { .... } public void myMethod() {...} }
  • 56. Managed Bean vs. EJB and REST
    • You could see everything as a Managed Bean with extra services
    • 57. An EJB is a Managed Bean with :
      • Transaction support
      • 58. Security
      • 59. Thread safety
    • A REST service is a Managed Bean with
      • HTTP support
  • 60. Interceptors 1.1: What is it?
    • Address cross-cutting concerns in Java EE
    • 61. Was part of the EJB 3.0 spec
    • 62. Now a separate spec shipped with EJB 3.1
    • 63. Can be uses in EJBs...
    • 64. … as well as ManagedBeans
    • 65. @AroundInvoke
  • 66. Managed Beans 1.0: Example @ManagedBean @Interceptors(LoggingInterceptor.class) public class MyPojo { public void myMethod() {...} } public class LoggingInterceptor { @AroundInvoke public Object logMethod(InvContext ic) {...} }
  • 67. Demo : Managed Bean & Interceptor
    • Create a managed bean “ IsbnGenerator ”
    • 68. Inject the managed bean through @Resource (works only under a container environment)
    • 69. Use an interceptor for logging
    • 70. Use “appclient” container (from GlassFish) to run it
  • 71. Dependency Injection for Java (DI) 1.0 (JSR 330) & Context and Dependency Injection (CDI) 1.0 (JSR 299)
  • 72.
    • Stands for “Dependency Injection for Java”
    • 73. Java EE 5 has resource injection
      • @Resource, @PersistenceContext, @EJB
    • But there is no application level injection in Java EE 5
    • 74. DI 1.0 introduces @Inject annotation (and others) for application level injection
    • 75. Spec. leads are Bob Lee (from Google) and Rod Johnson (from SpringSource)
    DI 1.0 (JSR 330): What & Why?
  • 76.
    • javax.inject package
    • 77. @Inject : Identifies injectable constructors, methods, and fields
    • 78. @Named : String-based qualifier (for EL)
    • 79. @Qualifier : Identifies qualifier
    • 80. @Scope : Identifies scope annotations
    • 81. @Singleton : Instantiates once
    DI 1.0 (JSR 330)
  • 82.
    • Used to be called “WebBeans”
    • 83. Uses annotations defined in DI 1.0 (JSR-330)
    @Inject ShoppingCart cart;
    • Bean discovery and wiring
      • Container discovers beans and wires everything together automatically
    • Let you use EJBs directly as JSF backing beans
    • 84. Every object managed by CDI has a well-defined scope
      • @Dependent, @ConversationalScoped, @RequestScoped, @SessionScoped, @ApplicationScoped,
    CDI 1.0 (JSR-299)
  • 85.
    • Injected type is identified by
      • Qualifier(s) + Java type
      • 86. e.g. @Inject @LoggedIn User user;
      • 87. Qualifier is used to narrow down a particular class when more than one candidate for injection exists
    • Context management with scopes
      • @ConversationScoped
      • 88. public class ShoppingCart { … }
    CDI 1.0 (JSR-299)
  • 89. 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
  • 90. Demo: How to Check Out “ glassfish-samples” www.javapassion.com/handsonlabs/javaee6_examples/#Exercise_1
  • 91. Demo: DI & CDI “ webbeans-guess” (Available from “ glassfish-samples” project)
  • 92. JPA 2.0
  • 93. JPA 2.0 Features
    • Richer mappings
    • 94. Richer JPQL
    • 95. Pessimistic Locking
    • 96. Criteria API
    • 97. Cache API
    • 98. Many more
  • 99. JPA 2.0: Richer Mapping
    • Supports collection of basic types and embeddables
      • In JPA 1.0, only collections of entities were supported
    • Supports multiple levels of embeddables
    • 100. Embeddables containing collection of embeddables and basic types
    • 101. PK can be derived entities
    • 102. More support for Maps...
  • 103. JPA 2.0: Collection of basic types @Entity Public class Item { @ElementCollection private Set<String> tags; } @Entity Public class Item { @ElementCollection @CollectionTable(name=&quot;TAGS&quot;) private Set<String> tags; } Mapped by default in ITEM_TAGS Mapped in TAGS
  • 104. JPA 2.0: Richer JPQL
    • Added entity type to support non-polymorphic queries
    • 105. Allow joins in subquery FROM clause
    • 106. Added new operators
      • INDEX (for ordered lists)
      • 107. CASE (for case expressions)
      • 108. more
    • Added new reserved words
      • ABS, BOTH, CONCAT, ELSE, END, ESCAPE, LEADING, LENGTH, LOCATE, SET, SIZE, SQRT, SUBSTRING, TRAILING
  • 109. Example: JPQL CASE Expression @Entity public class Employee { @Id Integer empId; String name; Float salary; Integer rating; // ... } UPDATE Employee e SET 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
  • 110. JPA 2.0: Standard Properties
    • In persistence.xml :
      • javax.persistence.jdbc.driver
      • 111. javax.persistence.jdbc.url
      • 112. javax.persistence.jdbc.user
      • 113. javax.persistence.jdbc.password
  • 114. JPA 2.0: Locking Enhancements
    • JPA 1.0 supports only optimist locking
    • 115. JPA 2.0 adds pessimistic locking
    • 116. Multiple places to specify lock
      • read and lock
      • 117. read then lock
      • 118. read then lock and refresh
    public enum LockModeType { OPTIMISTIC, OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC, PESSIMISTIC_FORCE_INCREMENT, NONE }
  • 119. 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
  • 120. 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
  • 121. 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
  • 122. 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
  • 123. JPA 2.0: Criteria API
    • Strongly typed criteria API
    • 124. Object-based query definition objects
      • rather than string-based
    • Like JPQL
    • 125. Uses a metamodel – Compile time type checking using Generics
      • Each entity X has a metamodel class X_
      • 126. Criteria API operates on the metamodel
  • 127. JPA 2.0: Criteria API Example #1 // Retrieve all orders whose lineitems is empty. // Using Criteria API CriteriaBuilder qb = em.getEntityManagerFactory().getCriteriaBuilder(); CriteriaQuery<Order> cq = qb.createQuery(Order.class); Root<Order> order = cq.from(Order.class); cq.where(qb.isEmpty(order.get(Order_.lineitems))).select(order); // Using JPQL SELECT o FROM Order o WHERE o.lineItems IS EMPTY
  • 128. JPA 2.0: Criteria API Example #2 // Using Criteria API CriteriaBuilder qb = em.getEntityManagerFactory().getCriteriaBuilder(); CriteriaQuery<Customer> q = qb.createQuery(Customer.class); Root<Customer> customer = q.from(Customer.class); Join<Customer,Order> order = customer.join(Customer_.orders, JoinType.LEFT); q.where(qb.equal(customer.get(Customer_.status), 1)) .select(customer); // Using JPQL SELECT c FROM Customer c LEFT JOIN c.orders o WHERE c.status = 1
  • 129. JPA 2.0: Caching
    • Supports the use of a second-level cache
    • 130. Cache API
      • contain(Class, PK)
      • 131. evict(Class, PK), evict(Class)
      • 132. evictAll()
    • @Cacheable annotation on entities
  • 133. Demo : Book Entity
  • 134. Servlet 3.0
  • 135.
    • Ease of Development
      • Through annotation
    • Dynamic registration of Servlets and Filters
      • During runtime
    • Pluggability (of 3rd-party frameworks/libs)
      • No more tweaking of web.xml is needed
    • Asynchronous Servlet
      • Support Comet applications
    • Security enhancements
    Servlet 3.0 Features
  • 136. // 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
  • 137. 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 ( &quot;DynamicServlet&quot;, &quot;com.mycom.MyServlet&quot;); dynamic. addMapping (&quot;/dynamicServlet&quot;); dynamic. setAsyncSupported (true); Dynamic Registration of Servlets/Filters
  • 138. Demo: Servlet 3.0 Featuers: Annotation, Dynamic Registration (Available from “ glassfish-samples” project)
  • 139. Pluggability (of 3 rd party Frameworks)
    • Make it possible to use 3rd-party framework and libraries without configuration in web.xml
    • 140. A framework is provided as a self-contained jar file
    • 141. All you have to do use the framework is to place the self-contained jar file under /WEB-INF/lib directory
  • 142. Pluggability: Modularization of web.xml
    • No more tweaking of single web.xml
    • 143. Each framework defines its own web-fragment.xml
      • Declare their own controller servlet
      • 144. Declare listener and filters
    • Container then collects them all
    • 145. Overridden by main web.xml
      • Order of the frameworks/libs can be specified in the web.xml
  • 146.
    • A self-contained framework is provided as a jar file and placed under WEB-INF/lib
      • web.xml (optional)
      • 147. WEB-INF/lib/ someframework1.jar ->
    META-INF/web-fragment.xml
      • WEB-INF/lib/ someframework2.jar ->
    META-INF/web-fragment.xml Pluggability – Modularization of web.xml
  • 148. Pluggability - web-fragment.xml <web-fragment> <servlet> <servlet-name>MyFramework</servlet-name> <servlet-class>com.mycom.MyFrameworkServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>MyFramework</servlet-name> <url-pattern>/MyFramework</url-pattern> </servlet-mapping> ... </web-fragment>
  • 149. Demo: Servlet 3.0 Featuers: Pluggability “ absolute-ordering-web-fragments” (Available from “ glassfish-samples” project)
  • 150. Asynchronous Servlet
    • Async. Servlets are for preventing “thread starvation” in cases such as following in standard (thus portable) fashion
      • Waiting for resources (eg JDBC connection)
      • 151. Waiting for Comet events (eg Published message in Comet-based Chat application)
      • 152. Waiting for responses (eg web services)
    • Better scalability
  • 153. Asynch. Servlet: Blocked vs. Asynch. Waiting for Web Services Blocking Asynchronous Thread blocked WS request In parallel
  • 154. import javax.servlet.*; Queue<AsyncContext> usersQueue; BlockingQueue<String> messageQueue; @WebServlet(urlPatterns = {&quot;/chat&quot;}, 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)
  • 155. doPost (...) { // also deal with system (login) messages String message = req.getParameter(&quot;message&quot;); 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)
  • 156. Demo: Servlet 3.0 Featuers: Comet using Asynch. API (Available from “ glassfish-samples” project)
  • 157. Demo : Add a Servlet
  • 158. EJB 3.1
  • 159.
    • Packaging in a war file
    • 160. Optional Local Interfaces
    • 161. Singleton
    • 162. Asynchronous calls
    • 163. Cron-based Timer Service
    • 164. Embeddable Container
    • 165. EJB Lite
    EJB 3.1
  • 166. Packaging in a war file
    • EJB components can be packaged directly inside a web application archive (war file)
  • 167. Demo: EJB 3.1: Simplified Packaging
  • 168. EJB 3.1: Optional Local Interface
    • One source file for bean
    @Stateless public class HelloBean { // No interface public String sayHello() { return &quot;Hello Brazil!&quot;; } }
  • 169. EJB 3.1: Asynchronous calls @Stateless public class OrderBean { public void createOrder() { Order order = persistOrder(); sendEmail(order) ; } public Order persistOrder() {...} @Asynchronous public Future<Long> sendEmail(Order order){ ...} }
  • 170. EJB 3.1: Timer Service @Stateless public class WakeUpBean { @Schedule(dayOfWeek=&quot;Mon-Fri&quot;, hour=&quot;9&quot;) void wakeUp() { ... } }
  • 171. Demo : Add an EJB stateless
  • 172. EJB 3.1: Singleton
    • One single instance per application
    • 173. Share state
    • 174. @Singleton
    • 175. Support for container-managed concurrency and bean-managed concurrency
      • @ConcurrencyManagement
  • 176. EJB 3.1: Singleton @Singleton public 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); } }
  • 177. Demo : Add a Singleton EJB
  • 178. EJB 3.1: Embeddable Container
    • API allowing to :
      • Initialize a container
      • 179. Get container ctx
    • Can run in any Java SE environment
      • Batch processing
      • 180. Simplifies testing
      • 181. Just a jar file in your classpath
    Java SE Transaction manager Security system Messaging engine EJB 3.1 Embedded container
  • 182. EJB 3.1: Embeddable Container ... public static void main(String[] args){ EJBContainer container = EJBContainer.createEJBContainer(); Context context = container.getContext(); Hello h = (Hello) context .lookup(&quot;java:global/classes/HelloEJB&quot;); h .sayHello; container.close(); } ...
  • 183. Demo : EJB Container Test
  • 184. JSF 2.0
  • 185. JSF 2.0
    • Annotation based
      • faces-config.xml is optional
    • Easy navigation
    • 186. Page description language
      • Facelets (preferred)
      • 187. JSP (still supported)
    • Templating
    • 188. Composite components
    • 189. Ajax support
  • 190. General JSF Architecture
  • 191. JSF 2.0: Managed Bean Annotation
    • <h:inputText value=&quot;#{login.name}&quot;/>
    • 192. JSF 1.0 – in faces-config.xml
    <managed-bean> <managed-bean-name>login</managed-bean> <managed-bean-class>com.corejsf.Login</managed-bean> <managed-bean-scope>session</managed-bean-scope> </managed-bean>
    • JSF 2.0 – faces-config.xml is optional
    @ManagedBean @SessionScoped public class Login { ... }
  • 193. JSF 2.0: Easy Navigation
    • <h:commandButton value=&quot;Press me!&quot; action=&quot;next&quot;/>
    • 194. JSF 1.0 – in faces-config.xml
    <navigation-rule> <navigation-case> <from-outcome>next</from-outcome> <to-view-id>/next.jsp</to-view-id> </navigation-case> </navigation-rule>
    • JSF 2.0
    <h:commandButton value=&quot;Press me!&quot; action=&quot;next&quot;/>
  • 195. JSF 2.0: Facelets
    • Preferred view handler in JSF
      • Addresses problems of using JSP with JSF
    • XHTML
    • 196. Pages are usable from HTML editors
    • 197. Templating
    • 198. Composite components
  • 199. Demo : Add a JSF page
  • 200. JSF 2.0: Composite Components
    • Made up of simpler components
    • 201. True JSF component
    • 202. Much easier to build in JSF 2.0 (than in JSF 1.0)
      • Single file, No Java code is needed
      • 203. NetBeans 6.8 provides “Convert to Composite Component” wizard
    • Can attach listeners, validators
  • 204. JSF 2.0: Composite Component
    • Declare a component
    <composite:interface> <composite:attribute name=&quot;who&quot; required=&quot;true&quot;/> </composite:interface> <composite:implementation> <span>Hello #{cc.attrs.who}</span> </composite:implementation>
    • Use it
    <html xmlns:ez=&quot;http://java.sun.com/jsf/composite/hello&quot;> <ez:hello who=&quot;world&quot; />
  • 205. Demo : Composite Component
  • 206. JSF 2.0: Ajax Support – Using tag
    • Very easy to use Ajax with JSF components
    <h:commandButton value=&quot;Create a book&quot; action=&quot;#{itemBean.doCreateBook}&quot;> <f:ajax execute=&quot;bookForm&quot; render=&quot;:booklist&quot;/> </h:commandButton>
    • Partial lifecycle executed for named components
  • 207. JSF 2.0: Ajax Support – Using JavaScript
    • Use jsf.js JavaScript library
    <h:outputScript name=&quot; jsf.js &quot; library=&quot;javax.faces&quot; target=&quot;head&quot;/> <h:commandButton value=&quot;Create a CD&quot; id=&quot;createButton&quot; onclick= &quot;jsf.ajax.request(this, event, {execute:'cdForm', render:'cdlist'}); return false;&quot; actionListener=&quot;#{itemBean.doCreateCD}&quot;/>
  • 208. Demo : JSF with Ajax
  • 209. Bean Validation 1.0
  • 210. Bean Validation 1.0: What is it?
    • Enable declarative validation in your applications
    • 211. Constrain Once, Validate Anywhere
      • restriction on a bean, field or property
      • 212. not null, size between 1 and 7, valid email...
    • Standard way to validate constraints
    • 213. Integration with JPA 2.0 & JSF 2.0
  • 214. Bean Validation 1.0: Example public class Address { @NotNull @Size(max=30, message=&quot;longer than {max} characters&quot;) private String street1; ... @NotNull @Valid private Country country; } public class Country { @NotNull @Size(max=30) private String name; ... }
  • 215. Demo : Validation Item/ItemBean
  • 216. JAX-RS 1.1
  • 217. JAX-RS 1.1
    • JAX-RS 1.0 has been released in 2008
      • RESTful Services
      • 218. POJO and Annotations Based
      • 219. Maps HTTP verbs (Get, Post, Put, Delete...)
    • JAX-RS 1.1
      • Part of Java EE 6
      • 220. EJB support
  • 221. JAX-RS 1.1: EJB Support @Path(&quot;/users/{userId}&quot;) @Stateless public class UserResource { @PersistenceContext EntityManage em; @GET @Produces(&quot;text/xml&quot;) public String getUser( @PathParam(&quot;userId&quot; ) String id){ User u = em.find(User.class, id) ... } }
  • 222. Demo : Add REST service to EJB
  • 223. Summary & Resources
  • 224. Summary
    • Java EE 6 is a standard based next generation enterprise application development and deployment platform
    • 225. Java EE 6 leverages proven best practice ideas
  • 226. Resources
    • Sun's Java EE homesite
      • http://java.sun.com/javaee/
    • Sang Shin's Advanced “Java EE programming” online course
      • www.javapassion.com/javaee_advanced/
    • “ Java EE 6 with GlassFish 3” book written by Antonio Goncalves
  • 227. 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)
    • 228. Many demos are from “glassfish-sample” project
  • 229. THANK YOU! Carol McDonald