SlideShare a Scribd company logo
Java EE 6 = Less Code + More Power
Arun Gupta, Java EE & GlassFish Guy
blogs.oracle.com/arungupta, @arungupta




                                         1
The following is intended to outline our general
product direction. It is intended for information
purposes only, and may not be incorporated into
any contract. It is not a commitment to deliver any
material, code, or functionality, and should not be
relied upon in making purchasing decisions.

The development, release, and timing of any
features or functionality described for Oracle's
products remains at the sole discretion of Oracle.
The Java EE 6 Platform

   Servlets 3.0      JPA 2.0           EJB 3.1    JDBC      StAX

                   Interceptors
     JSF 2.0                           JAX-RS     JNDI     JavaMail
                        1.1

                       Bean
   EJB 3.1 Lite                         JAXB      JMS       JACC
                   Validation1.0

     JSP 2.2         CDI 1.0           JAX-WS     JAXP      SAAJ

                    Managed
     JTA 1.1                           JASPIC    JAX-RPC     ...
                    Beans 1.0




                                   Contributed
                                   by RedHat       New     Updated
 Web Profile 1.0
Light-weight
â—Ź   Java EE 6 Web Profile
â—Ź   Pruning
    â—Ź   Pruned today, means
        –   Optional in the next release
        –   Deleted in the subsequent releases
    â—Ź   Technologies marked in Javadocs
        –   EJB 2.x Entity Beans, JAX-RPC, JAXR, JSR 88
â—Ź   EJB-in-WAR
â—Ź   No-interface EJB
â—Ź   Optional
    “web.xml”/”faces-
    config.xml”
â—Ź   Annotation-driven
    â—Ź   @Schedule
    â—Ź   @Path
    â—Ź   @Inject
    â—Ź   ...
<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>
Java EE 6 workshop at Dallas Tech Fest 2011
From the real users ...                                                  Jigsaw puzzle, Modular,
                                                                             standard, less xml, easy,
 Developers can concentrate                                                  easy, have I said easy?
 on business logic, Java EE 6 is
 providing a standard for               Standards compliance, vendor
 the infrastructure.                    independence, milliseconds
                                        and kilobyte deployment
                                                                              Faster development, less
                                                                              frameworks, less
                                                                              complexity, more great
Higher integrated specs,
                                                                              code shipped
simple and annotation driven,
single-classloader WARs,
next level of industry
standard                                  Definite excuse to avoid
                                          Spring forever

                                                                        Simplified Java
  Not your fat grandfather's                                            Development, Focus on
  enterprise Java anymore,                                              building great products
  enterprise Java renaissance


                      http://blogs.oracle.com/arungupta/tags/community+feedback
Compatible Java EE 6 Impls

Today:
                             Web Profile Only




Announced:
3.1 Overview
â—Ź   Built on GlassFish 3
â—Ź   Modular and Extensible HK2 Kernel
    â—Ź   ~260+ modules
    â—Ź   OSGi/Java EE Hybrid Apps
â—Ź   Clustering and High Availability
    â—Ź   HTTP, EJB, IIOP, SSO, Metro
â—Ź   Containers start on demand
â—Ź   End-to-end extensibility
Sample App Overview

  CLI

                            JPA


 Servlet         EJB              Database



           CDI     JAX-RS
  JSF
What will we do ?
1. Generate JPA Entities from the database table
2. Refactor generated entities for a more intuitive O/R mapping
3. Create an EJB for querying the database
4. Create a Servlet for testing the EJB and displaying values
    from the database table
5. Enable CDI and make the EJB EL-injectable
6. Display the values in JSF2/Facelets-based view
7. Expose JPA entities as a RESTful resource by using JAX-RS
What will we use ?
Generate JPA Entities
And customize them



    CLI

                                      JPA


  Servlet                  EJB              Database



                     CDI     JAX-RS
   JSF
Java Persistence API 2
â—Ź   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]
Create an EJB
For querying the database



    CLI

                                     JPA


   Servlet                EJB              Database



                    CDI     JAX-RS
    JSF
Create an EJB – Sample Code
For querying the database

@PersistenceContext
EntityManager em;



public List<Customer> getCustomers() {
return (List<Customer>)em.createNamedQuery("Customer.findAll").getResultList();
}
EJB 3.1
â—Ź   Simplified Packaging
●   No interface view – one source file per bean
â—Ź   Embeddable API
â—Ź   @Singleton
    â—Ź   Initialization in @PostContruct
â—Ź   Simplified Cron-like syntax for Timer
â—Ź   Asynchronous Session Bean
â—Ź   Portable Global JNDI Name
Create a Servlet
For testing EJB and display values from the database



    CLI

                                      JPA


   Servlet                 EJB              Database



                     CDI     JAX-RS
    JSF
Create a Servlet – Sample Code
For testing EJB and display values from the database

@EJB CustomerSessionBean ejb;

out.println(ejb.getCustomers());

http://localhost:8080/JavaEE6SampleApp/TestServlet
Servlets 3.0
●   @WebServlet, @WebListener, @WebFilter, …
â—Ź   Asynchronous Servlets
    â—Ź   @WebServlet(asyncSupported=true)
â—Ź   Plugin libraries using web fragments
â—Ź   Dynamic registration of Servlets
â—Ź   WEB-INF/lib/[*.jar]/META-INF/resources
     accessible in the root
â—Ź   Programmatic authentication login/logout
â—Ź   Default Error Page
â—Ź   ...
Enable CDI
Make the EJB EL-injectable



    CLI

                                     JPA


   Servlet                EJB              Database



                    CDI     JAX-RS
    JSF
Enable CDI – Sample Code
Make the EJB EL-injectable

@javax.inject.Named
Contexts & Dependency Injection
â—Ź   Standards-based Dependency Injection
●   Type-safe – Buids on @Inject API
â—Ź   Context/Scope management
â—Ź   Strong Typing, Loose Coupling
â—Ź   Includes ELResolver
            @Inject @LoggedIn User user

Request                                What ?
Injection          Which one ?
                    (Qualifier)        (Type)
CDI

â—Ź   Qualifiers
â—Ź   Events
â—Ź   Stereotypes
â—Ź   Interceptors
â—Ź   Decorators
â—Ź   Alternatives
â—Ź   ...
Display the values
In JSF2/Facelets-based view



    CLI

                                     JPA


   Servlet                EJB              Database



                    CDI     JAX-RS
    JSF
Display the values – Sample Code
In JSF2/Facelets-based view

http://localhost:8080/JavaEE6SampleApp/faces/index.xhtml

<h1>Java EE 6 Sample App</h1>

<center>Powered by GlassFish!</center>


<h:dataTable value="#{customerSessionBean.customers}" var="c">
<h:column>#{c.name}</h:column>
<h:column>#{c.customerId}</h:column>
</h:dataTable>
Java Server Faces 2.0
●   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
    â—Ź   ...
RESTful resource
Using JAX-RS



   CLI

                                JPA


  Servlet            EJB              Database



               CDI     JAX-RS
   JSF
RESTful resource – Sample Code
Using JAX-RS

@Path("/customers")


@GET
@Path("/customer/{id}")
@Produces("application/xml")
public Customer getCustomer(@PathParam("id")Integer id) {
return
(Customer)em.createNamedQuery("Customer.findByCustomerId").
setParameter("customerId", id).getSingleResult();
}


http://localhost:8080/JavaEE6SampleApp/resources/customers/customer/1

@Produces({"application/xml", "application/json"})
JAX-RS 1.1

â—Ź   Java API for building RESTful Web Services
â—Ź   POJO based
â—Ź   Annotation-driven
â—Ź   Server-side API
â—Ź   HTTP-centric
Sample App Review

  CLI

                            JPA


 Servlet         EJB              Database



           CDI     JAX-RS
  JSF
Java EE for the Cloud : JSR 342
â—Ź   More easily operate on private/public clouds
    â—Ź   Multi-tenancy
    â—Ź   Elasticity
    â—Ź   Service Provisioning
â—Ź   Tighter requirements for resource/state management
â—Ź   Better isolation between applications
â—Ź   Potential standard APIs for NRDBMS, Caching, other
â—Ź   Common management and monitoring interfaces
â—Ź   Better packaging
â—Ź   Evolution, not revolution
Java EE 7 : Technology Refresh
â—Ź   Ease-of-development: JMS 2.0
â—Ź   Latest web standards
    â—Ź   New JSRs: Web Sockets, Java JSON API
    â—Ź   HTTP Client API (JAX-RS 2.0)
â—Ź   Possible JSRs inclusion
    â—Ź   Concurrency Utilities for Java EE (JSR 236)
    â—Ź   JCache (JSR 107)
Java EE 7 – When ?
â—Ź   Late 2012
â—Ź   Date-driven release
    â—Ź   Anything not ready will be deferred to Java EE 8
â—Ź   Participate
    â—Ź   Expert Groups forming
    â—Ź   Public discussion lists
    â—Ź   JCP membership free for individuals
Transparency Checklist
http://jcp.org/en/resources/transparency
                                              NEW


â—Ź   EG members names
â—Ź   EG business reported on a 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
â—Ź   Find out what's new with Java technology
â—Ź   See new tools and techniques
â—Ź   Learn how to create solutions
â—Ź   Network with peers
â—Ź   Meet with experts
â—Ź   Influence the future of the Java platform
â—Ź   400+ sessions/BoFs/HOLs
â—Ź   ...                     oracle.com/javaone
References

â—Ź   oracle.com/javaee
â—Ź   glassfish.org
â—Ź   oracle.com/goto/glassfish
â—Ź   blogs.oracle.com/theaquarium
â—Ź   youtube.com/GlassFishVideos
â—Ź   Follow @glassfish
Java EE 6 = Less Code + More Power
Arun Gupta, Java EE & GlassFish Guy
blogs.oracle.com/arungupta, @arungupta




                                         39

More Related Content

PDF
Java EE 6 Component Model Explained
PDF
Java EE 6 & GlassFish 3
PDF
Sun Java EE 6 Overview
 
PDF
Java EE6 CodeCamp16 oct 2010
PDF
Overview of Java EE 6 by Roberto Chinnici at SFJUG
PDF
Java 7 workshop
PDF
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
PDF
JavaEE 6 and GlassFish v3 at SFJUG
Java EE 6 Component Model Explained
Java EE 6 & GlassFish 3
Sun Java EE 6 Overview
 
Java EE6 CodeCamp16 oct 2010
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Java 7 workshop
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
JavaEE 6 and GlassFish v3 at SFJUG

What's hot (20)

PDF
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010
PDF
Running your Java EE applications in the Cloud
PDF
Java EE 6 & GlassFish v3 @ DevNexus
PDF
Understanding the nuts & bolts of Java EE 6
PDF
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
PDF
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
PDF
The State of Java under Oracle at JCertif 2011
PDF
Glass Fishv3 March2010
PDF
Java EE6 Overview
PDF
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
PDF
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
PDF
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
PDF
Java EE 6 and GlassFish v3: Paving the path for future
PDF
Andrei Niculae - JavaEE6 - 24mai2011
PDF
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
PDF
Java EE 6 : Paving The Path For The Future
PDF
What's new in Java EE 6
PDF
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
PDF
Java EE7 Demystified
PDF
GIDS 2012: Java Message Service 2.0
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010
Running your Java EE applications in the Cloud
Java EE 6 & GlassFish v3 @ DevNexus
Understanding the nuts & bolts of Java EE 6
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
The State of Java under Oracle at JCertif 2011
Glass Fishv3 March2010
Java EE6 Overview
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 and GlassFish v3: Paving the path for future
Andrei Niculae - JavaEE6 - 24mai2011
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 : Paving The Path For The Future
What's new in Java EE 6
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
Java EE7 Demystified
GIDS 2012: Java Message Service 2.0
Ad

Similar to Java EE 6 workshop at Dallas Tech Fest 2011 (20)

PDF
Java EE 6 Aquarium Paris
ODP
OTN Developer Days - Java EE 6
PDF
Java E
PDF
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
PDF
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
PDF
Whats New In Java Ee 6
PDF
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
PDF
The Java EE 7 Platform: Developing for the Cloud (FISL 12)
PDF
Spark IT 2011 - Java EE 6 Workshop
PDF
Java EE 6 = Less Code + More Power
PDF
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
PDF
The Java Ee 6 Platform Normandy Jug
 
PDF
Java EE 6, Eclipse @ EclipseCon
PDF
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
PDF
S313557 java ee_programming_model_explained_dochez
PDF
GlassFish Tool Bundle for Eclipse
PDF
Java EE 6 and GlassFish portfolio
PDF
Java Enterprise Edition 6 Overview
PDF
Boston 2011 OTN Developer Days - Java EE 6
PDF
Java EE 7: the Voyage of the Cloud Treader
Java EE 6 Aquarium Paris
OTN Developer Days - Java EE 6
Java E
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Whats New In Java Ee 6
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
The Java EE 7 Platform: Developing for the Cloud (FISL 12)
Spark IT 2011 - Java EE 6 Workshop
Java EE 6 = Less Code + More Power
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
The Java Ee 6 Platform Normandy Jug
 
Java EE 6, Eclipse @ EclipseCon
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
S313557 java ee_programming_model_explained_dochez
GlassFish Tool Bundle for Eclipse
Java EE 6 and GlassFish portfolio
Java Enterprise Edition 6 Overview
Boston 2011 OTN Developer Days - Java EE 6
Java EE 7: the Voyage of the Cloud Treader
Ad

More from Arun Gupta (20)

PDF
5 Skills To Force Multiply Technical Talents.pdf
PPTX
Machine Learning using Kubernetes - AI Conclave 2019
PDF
Machine Learning using Kubeflow and Kubernetes
PPTX
Secure and Fast microVM for Serverless Computing using Firecracker
PPTX
Building Java in the Open - j.Day at OSCON 2019
PPTX
Why Amazon Cares about Open Source
PDF
Machine learning using Kubernetes
PDF
Building Cloud Native Applications
PDF
Chaos Engineering with Kubernetes
PDF
How to be a mentor to bring more girls to STEAM
PDF
Java in a World of Containers - DockerCon 2018
PPTX
The Serverless Tidal Wave - SwampUP 2018 Keynote
PDF
Introduction to Amazon EKS - KubeCon 2018
PDF
Mastering Kubernetes on AWS - Tel Aviv Summit
PDF
Top 10 Technology Trends Changing Developer's Landscape
PDF
Container Landscape in 2017
PDF
Java EE and NoSQL using JBoss EAP 7 and OpenShift
PDF
Docker, Kubernetes, and Mesos recipes for Java developers
PDF
Thanks Managers!
PDF
Migrate your traditional VM-based Clusters to Containers
5 Skills To Force Multiply Technical Talents.pdf
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubeflow and Kubernetes
Secure and Fast microVM for Serverless Computing using Firecracker
Building Java in the Open - j.Day at OSCON 2019
Why Amazon Cares about Open Source
Machine learning using Kubernetes
Building Cloud Native Applications
Chaos Engineering with Kubernetes
How to be a mentor to bring more girls to STEAM
Java in a World of Containers - DockerCon 2018
The Serverless Tidal Wave - SwampUP 2018 Keynote
Introduction to Amazon EKS - KubeCon 2018
Mastering Kubernetes on AWS - Tel Aviv Summit
Top 10 Technology Trends Changing Developer's Landscape
Container Landscape in 2017
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Docker, Kubernetes, and Mesos recipes for Java developers
Thanks Managers!
Migrate your traditional VM-based Clusters to Containers

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
 
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPT
Teaching material agriculture food technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Empathic Computing: Creating Shared Understanding
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
 
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
 
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Programs and apps: productivity, graphics, security and other tools
Mobile App Security Testing_ A Comprehensive Guide.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Empathic Computing: Creating Shared Understanding
The Rise and Fall of 3GPP – Time for a Sabbatical?
 
Per capita expenditure prediction using model stacking based on satellite ima...
Review of recent advances in non-invasive hemoglobin estimation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Diabetes mellitus diagnosis method based random forest with bat algorithm
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Chapter 3 Spatial Domain Image Processing.pdf
cuic standard and advanced reporting.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing

Java EE 6 workshop at Dallas Tech Fest 2011

  • 1. Java EE 6 = Less Code + More Power Arun Gupta, Java EE & GlassFish Guy blogs.oracle.com/arungupta, @arungupta 1
  • 2. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle's products remains at the sole discretion of Oracle.
  • 3. The Java EE 6 Platform Servlets 3.0 JPA 2.0 EJB 3.1 JDBC StAX Interceptors JSF 2.0 JAX-RS JNDI JavaMail 1.1 Bean EJB 3.1 Lite JAXB JMS JACC Validation1.0 JSP 2.2 CDI 1.0 JAX-WS JAXP SAAJ Managed JTA 1.1 JASPIC JAX-RPC ... Beans 1.0 Contributed by RedHat New Updated Web Profile 1.0
  • 4. Light-weight â—Ź Java EE 6 Web Profile â—Ź Pruning â—Ź Pruned today, means – Optional in the next release – Deleted in the subsequent releases â—Ź Technologies marked in Javadocs – EJB 2.x Entity Beans, JAX-RPC, JAXR, JSR 88
  • 5. â—Ź EJB-in-WAR â—Ź No-interface EJB â—Ź Optional “web.xml”/”faces- config.xml” â—Ź Annotation-driven â—Ź @Schedule â—Ź @Path â—Ź @Inject â—Ź ...
  • 6. <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>
  • 8. From the real users ... Jigsaw puzzle, Modular, standard, less xml, easy, Developers can concentrate easy, have I said easy? on business logic, Java EE 6 is providing a standard for Standards compliance, vendor the infrastructure. independence, milliseconds and kilobyte deployment Faster development, less frameworks, less complexity, more great Higher integrated specs, code shipped simple and annotation driven, single-classloader WARs, next level of industry standard Definite excuse to avoid Spring forever Simplified Java Not your fat grandfather's Development, Focus on enterprise Java anymore, building great products enterprise Java renaissance http://blogs.oracle.com/arungupta/tags/community+feedback
  • 9. Compatible Java EE 6 Impls Today: Web Profile Only Announced:
  • 10. 3.1 Overview â—Ź Built on GlassFish 3 â—Ź Modular and Extensible HK2 Kernel â—Ź ~260+ modules â—Ź OSGi/Java EE Hybrid Apps â—Ź Clustering and High Availability â—Ź HTTP, EJB, IIOP, SSO, Metro â—Ź Containers start on demand â—Ź End-to-end extensibility
  • 11. Sample App Overview CLI JPA Servlet EJB Database CDI JAX-RS JSF
  • 12. What will we do ? 1. Generate JPA Entities from the database table 2. Refactor generated entities for a more intuitive O/R mapping 3. Create an EJB for querying the database 4. Create a Servlet for testing the EJB and displaying values from the database table 5. Enable CDI and make the EJB EL-injectable 6. Display the values in JSF2/Facelets-based view 7. Expose JPA entities as a RESTful resource by using JAX-RS
  • 13. What will we use ?
  • 14. Generate JPA Entities And customize them CLI JPA Servlet EJB Database CDI JAX-RS JSF
  • 15. Java Persistence API 2 â—Ź 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]
  • 16. Create an EJB For querying the database CLI JPA Servlet EJB Database CDI JAX-RS JSF
  • 17. Create an EJB – Sample Code For querying the database @PersistenceContext EntityManager em; public List<Customer> getCustomers() { return (List<Customer>)em.createNamedQuery("Customer.findAll").getResultList(); }
  • 18. EJB 3.1 â—Ź Simplified Packaging â—Ź No interface view – one source file per bean â—Ź Embeddable API â—Ź @Singleton â—Ź Initialization in @PostContruct â—Ź Simplified Cron-like syntax for Timer â—Ź Asynchronous Session Bean â—Ź Portable Global JNDI Name
  • 19. Create a Servlet For testing EJB and display values from the database CLI JPA Servlet EJB Database CDI JAX-RS JSF
  • 20. Create a Servlet – Sample Code For testing EJB and display values from the database @EJB CustomerSessionBean ejb; out.println(ejb.getCustomers()); http://localhost:8080/JavaEE6SampleApp/TestServlet
  • 21. Servlets 3.0 â—Ź @WebServlet, @WebListener, @WebFilter, … â—Ź Asynchronous Servlets â—Ź @WebServlet(asyncSupported=true) â—Ź Plugin libraries using web fragments â—Ź Dynamic registration of Servlets â—Ź WEB-INF/lib/[*.jar]/META-INF/resources accessible in the root â—Ź Programmatic authentication login/logout â—Ź Default Error Page â—Ź ...
  • 22. Enable CDI Make the EJB EL-injectable CLI JPA Servlet EJB Database CDI JAX-RS JSF
  • 23. Enable CDI – Sample Code Make the EJB EL-injectable @javax.inject.Named
  • 24. Contexts & Dependency Injection â—Ź Standards-based Dependency Injection â—Ź Type-safe – Buids on @Inject API â—Ź Context/Scope management â—Ź Strong Typing, Loose Coupling â—Ź Includes ELResolver @Inject @LoggedIn User user Request What ? Injection Which one ? (Qualifier) (Type)
  • 25. CDI â—Ź Qualifiers â—Ź Events â—Ź Stereotypes â—Ź Interceptors â—Ź Decorators â—Ź Alternatives â—Ź ...
  • 26. Display the values In JSF2/Facelets-based view CLI JPA Servlet EJB Database CDI JAX-RS JSF
  • 27. Display the values – Sample Code In JSF2/Facelets-based view http://localhost:8080/JavaEE6SampleApp/faces/index.xhtml <h1>Java EE 6 Sample App</h1> <center>Powered by GlassFish!</center> <h:dataTable value="#{customerSessionBean.customers}" var="c"> <h:column>#{c.name}</h:column> <h:column>#{c.customerId}</h:column> </h:dataTable>
  • 28. Java Server Faces 2.0 â—Ź 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 â—Ź ...
  • 29. RESTful resource Using JAX-RS CLI JPA Servlet EJB Database CDI JAX-RS JSF
  • 30. RESTful resource – Sample Code Using JAX-RS @Path("/customers") @GET @Path("/customer/{id}") @Produces("application/xml") public Customer getCustomer(@PathParam("id")Integer id) { return (Customer)em.createNamedQuery("Customer.findByCustomerId"). setParameter("customerId", id).getSingleResult(); } http://localhost:8080/JavaEE6SampleApp/resources/customers/customer/1 @Produces({"application/xml", "application/json"})
  • 31. JAX-RS 1.1 â—Ź Java API for building RESTful Web Services â—Ź POJO based â—Ź Annotation-driven â—Ź Server-side API â—Ź HTTP-centric
  • 32. Sample App Review CLI JPA Servlet EJB Database CDI JAX-RS JSF
  • 33. Java EE for the Cloud : JSR 342 â—Ź More easily operate on private/public clouds â—Ź Multi-tenancy â—Ź Elasticity â—Ź Service Provisioning â—Ź Tighter requirements for resource/state management â—Ź Better isolation between applications â—Ź Potential standard APIs for NRDBMS, Caching, other â—Ź Common management and monitoring interfaces â—Ź Better packaging â—Ź Evolution, not revolution
  • 34. Java EE 7 : Technology Refresh â—Ź Ease-of-development: JMS 2.0 â—Ź Latest web standards â—Ź New JSRs: Web Sockets, Java JSON API â—Ź HTTP Client API (JAX-RS 2.0) â—Ź Possible JSRs inclusion â—Ź Concurrency Utilities for Java EE (JSR 236) â—Ź JCache (JSR 107)
  • 35. Java EE 7 – When ? â—Ź Late 2012 â—Ź Date-driven release â—Ź Anything not ready will be deferred to Java EE 8 â—Ź Participate â—Ź Expert Groups forming â—Ź Public discussion lists â—Ź JCP membership free for individuals
  • 36. Transparency Checklist http://jcp.org/en/resources/transparency NEW â—Ź EG members names â—Ź EG business reported on a 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
  • 37. â—Ź Find out what's new with Java technology â—Ź See new tools and techniques â—Ź Learn how to create solutions â—Ź Network with peers â—Ź Meet with experts â—Ź Influence the future of the Java platform â—Ź 400+ sessions/BoFs/HOLs â—Ź ... oracle.com/javaone
  • 38. References â—Ź oracle.com/javaee â—Ź glassfish.org â—Ź oracle.com/goto/glassfish â—Ź blogs.oracle.com/theaquarium â—Ź youtube.com/GlassFishVideos â—Ź Follow @glassfish
  • 39. Java EE 6 = Less Code + More Power Arun Gupta, Java EE & GlassFish Guy blogs.oracle.com/arungupta, @arungupta 39