SlideShare una empresa de Scribd logo
1 de 65
Descargar para leer sin conexión
Enterprise JavaBeans 3.1
                   Bert Ertman
                berte@infosupport.com
Enterprise JavaBeans 3.1
Bert	
  Ertman
Technology	
  Manager
Competence	
  Center	
  Java


Co-­‐lead	
  NLJUG,	
  Sun/Oracle	
  recognized	
  Java	
  Champion
Author	
  and	
  editorial	
  board	
  member	
  
for	
  Dutch	
  Java	
  Magazine

E-­‐mail:	
  berte@infosupport.com
Follow	
  me	
  on	
  TwiLer:	
  @BertErtman
J2EE
  #fail
          #fail


           EJB
                  #fail
BeJUG Evening Session - Enterprise JavaBeans 3.1
Agenda


           • EJB 3: short recap
           • What’s new in EJB 3.1
               •    Ease-of-use improvements

               •    EJB Lite

               •    New features



BeJUG Evening Session - Enterprise JavaBeans 3.1
The 3 minutes introduction to EJB 3




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: EJB 2.x Session Bean




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: EJB 2.x Deployment Descriptor




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: EJB 2.x Client View




BeJUG Evening Session - Enterprise JavaBeans 3.1
blissful ignorance
          or painful truth of reality?




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: EJB 3.x Session Bean




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: EJB 3.x Deployment Descriptor




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: EJB 3.x Client View




BeJUG Evening Session - Enterprise JavaBeans 3.1
How did they do that?
           •    Configuration by exception with sensible defaults
               •    Transaction type defaults to CONTAINER

               •    Transaction attribute defaults to REQUIRED

               •    Security permissions defaults to UNCHECKED

           •    Use Annotations
               •    To choose explicitly (recommended)

               •    To override defaults

           •    Deployment descriptor is no longer required
               •    But can override above configurations


BeJUG Evening Session - Enterprise JavaBeans 3.1
EJB 3 Programming Model


                                                                   2. Invokes middleware services:
                                                                       Lifecycle mgmt, trx mgmt,
                                                                       Persistence, security, etc.
                            1. Call a method




                                  4. Return from call



                                         3. Invoke corresponding
                                          method on bean class
                                                                    4. Return outcome




BeJUG Evening Session - Enterprise JavaBeans 3.1
So, what’s new in EJB 3.1?




BeJUG Evening Session - Enterprise JavaBeans 3.1
EJB 3.1


           • Separate JSR (318)
               •    Evolve separately from JPA

               •    Focus on ease-of-use

           • Expert group formed - Aug 2007
           • Final release - December 2009

BeJUG Evening Session - Enterprise JavaBeans 3.1
Ease-of-use improvements


           • Optional Local Business interface
           • Simplified packaging
           • EJB-Lite
           • Portable JNDI names
           • Simple component testing

BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: Session Bean with Local Business
                           interface




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: Session Bean without Local
                         Business interface




BeJUG Evening Session - Enterprise JavaBeans 3.1
Simplified packaging

           • Goal is to remove artificial packaging
                restrictions
               •    All resources are shared within .war

               •    Web application APIs are not exposed to
                    EJB components

           • ejb-jar.xml is still optional
               •    If needed, placed in WEB-INF


BeJUG Evening Session - Enterprise JavaBeans 3.1
Java EE 5 packaging




BeJUG Evening Session - Enterprise JavaBeans 3.1
Simplified packaging




BeJUG Evening Session - Enterprise JavaBeans 3.1
EJB 3.1
                                       lite

BeJUG Evening Session - Enterprise JavaBeans 3.1
EJB 3.1 “Lite”



           • Small subset of EJB 3.1 API required by
                Java EE 6 Web Profile
           • Broadens the availability of EJB
                technology without losing portability




BeJUG Evening Session - Enterprise JavaBeans 3.1
Specs are ok:

            Blond hair,
            blue eyes,
             red lips,                             EJB HEAVY
           pink thong...

                   BUT...


              EJB lite
BeJUG Evening Session - Enterprise JavaBeans 3.1
Lite vs Full

     •    EJB Lite:                                •   Full = Lite + ...
         •   Local Session Beans                       •   Message Driven Beans

         •   CMT / BMT                                 •   EJB Web Service
                                                           Endpoints
         •   Declarative Security

         •   Interceptors                              •   RMI-IIOP Interop

         •   Web Profile also includes                 •   2.x / 3.x Remote view
             JPA 2.0                                   •   2.x Local view

                                                       •   Timer Service

                                                       •   CMP / BMP Entities

BeJUG Evening Session - Enterprise JavaBeans 3.1
Portable global JNDI names

           • Spec-defined lookup names for Remote
                and Local session beans
           • Three main goals :
               •    Simplify intra-application Local Session
                    lookups

               •    Simplify mapping of cross-application
                    Remote session bean dependencies

               •    Improve portability of Remote Java clients


BeJUG Evening Session - Enterprise JavaBeans 3.1
Portable naming syntax
         • Each session bean gets the following
              entries :
               •    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>


BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: remote session bean with remote
                             client



                                                   Bean deployed as
                                                    part of hello.jar




BeJUG Evening Session - Enterprise JavaBeans 3.1
EJB component testing


           • Session Beans were always hard to test
               •    Unit-testing was possible, but what about
                    container resources?

               •    Automated integration testing required

           • Now supported with in-process EJB
                container


BeJUG Evening Session - Enterprise JavaBeans 3.1
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, ...

               •    “Single Application” model

               •    Only required to support 3.1 “Lite” API

           •    Vendors can optionally support additional
                functionality

BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: Embeddable API




BeJUG Evening Session - Enterprise JavaBeans 3.1
New features

           • Singletons
           • Startup / shutdown callbacks
           • Calendar-based timers / automatic
                timer creation
           • Asynchronous invocations
           • JAX-RS integration
BeJUG Evening Session - Enterprise JavaBeans 3.1
Singletons

           • One instance per application, per JVM
               •    Not intended to provide cluster-wide singleton

           • Fits into existing dependency injection
                architecture
               •    Access through @EJB or lookup

               •    Intended for sharing data within entire
                    application (not just EJB components)

               •    Designed for concurrent access


BeJUG Evening Session - Enterprise JavaBeans 3.1
Lifecycle of a singleton session bean

                                            Does not exist




                                                             Class.newInstance()
                            @PreDestroy                      Dependency injections
                                                             @PostConstruct




                                            Method-ready
                 Business method




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: simple singleton usage




BeJUG Evening Session - Enterprise JavaBeans 3.1
Singleton concurrency options

           • Single threaded (default)
               •    For consistency with all existing bean types

           • Container Managed Concurrency
               •    Control access via method-level locking
                    metadata

           • Bean Managed Concurrency
               •    All concurrent invocations have access to
                    bean instance

BeJUG Evening Session - Enterprise JavaBeans 3.1
Container Managed Concurrency

           •    Concurrent access determined by method-
                level locking metadata
               •    READ lock: allow any number of concurrent
                    accesses to bean instance

               •    WRITE lock (default): ensure single-threaded bean
                    instance access

           •    Incoming invocations are blocked by container
                until the necessary lock can be acquired
           •    … or until an optional timeout has been
                reached

BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: read-only singleton
                            (container managed)




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: read-mostly singleton
                          (container managed)




BeJUG Evening Session - Enterprise JavaBeans 3.1
Bean Managed Concurrency


           • All incoming invocations allowed to
                access bean instance concurrently
               •    Bean developer is solely responsible for
                    maintaining integrity of instance state

               •    Can use synchronization primitives such as
                    synchronized, volatile




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: bean managed concurrency




BeJUG Evening Session - Enterprise JavaBeans 3.1
Application Startup/shutdown callbacks

           •    Uses singleton bean life cycle
           •    Full container services available
               •    Container-managed transactions

               •    Entity Managers, Timer Service, etc.

           •    Startup callback:
               •    @Startup and @PostConstruct

           •    Shutdown callback:
               • @PreDestroy
BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: startup/shutdown callbacks




BeJUG Evening Session - Enterprise JavaBeans 3.1
Timer Service enhancements



           • Calendar-based timeouts
           • Automatic timer creation
           • Non-persistent timers


BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: EJB 3.0 use of Timer Service




BeJUG Evening Session - Enterprise JavaBeans 3.1
Some (hard) lessons learned...

           • Difficult to configure calendar-based
                events using only relative time units
           • How to register the timer in the first
                place?
               •    Typical container events not a great fit; they
                    happen every time application initializes and
                    in every server instance
                   •   Burden is on developer to figure out if timer already exists

                   •   No way to guarantee that only one is created per cluster



BeJUG Evening Session - Enterprise JavaBeans 3.1
Calendar based timeouts

           •    Cron-like semantics with improved syntax
           •    Can be created programmatically or
                automatically
           •    Named attributes:
               •    second, minute, hour (default = “0”)

               •    dayOfMonth, month, dayOfWeek, year
                    (default = “*”)

           •    Relative to optionally specified time zone

BeJUG Evening Session - Enterprise JavaBeans 3.1
Calendar expression examples

           •    The last Thursday in November at 2 pm:
               •    (hour=”14”, dayOfMonth=”Last Thu”,
                     month=”Nov”)

           •    Every day at 3:15 am U.S. Eastern Time:
               •    (minute=”15”, hour=”3”,
                     timezone=”America/New_York”)

           •    Every twenty seconds:
               • (second=”*/20”,                   minute=”*”,
                      hour=”*”)


BeJUG Evening Session - Enterprise JavaBeans 3.1
Automatic Timer creation

           • Container creates timer automatically
                when application is being deployed:




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: non-persistent timers




BeJUG Evening Session - Enterprise JavaBeans 3.1
Simple asynchronous operations

           •    Use metadata to mark a Local/Remote
                business method as asynchronous
           •    Container returns control to client before
                executing business method
           •    No separate API to learn




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: local concurrent computation




BeJUG Evening Session - Enterprise JavaBeans 3.1
Asynchronous results
           •    Based on java.util.concurrent.Future

           •    Result value is returned via Future.get()

           •    Also supports Future.get(long,
                TimeUnit)

           •    Client exception wrapped by
                ExecutionException

               •    getCause() returns same exception as
                    would have been thrown by a synchronous
                    invocation

BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: Asynchronous operation result




                                                   AsyncResult<V>
                                                     implements
                                                      Future<V>




BeJUG Evening Session - Enterprise JavaBeans 3.1
JAX-RS support



           • Java API for XML RESTful Services
           • JSR-311 annotations can be used
                within Stateless Session Beans




BeJUG Evening Session - Enterprise JavaBeans 3.1
Example: Session Bean as JAX-RS resource




BeJUG Evening Session - Enterprise JavaBeans 3.1
Rod, I am your father
Spring
                                                             vs
                                                         Java EE 6


                                                 “Now that Java EE 6 is
                                                here…do I still need those
                                                proprietary frameworks?”




                    Lean Java EE 6 without Spring
“Java EE 6 provides similar benefits without tying you to a non-standard solution”
BeJUG Evening Session - Enterprise JavaBeans 3.1
Soon, in a store near you...

                                                    Bert Ertman
                                                     “I wrote this book
                                                                        for
                                                    developers who ha architects and
                                                                         ve grown increasin
                                                    frustrated with that                    gly
                                                                         annoying rebel
                                                   framework called
                                                                        Sp
                                                   you can do to impl ring. It shows what
                                                                        ement cleaner, m
                                                   productive and ab                     ore
                                                                       ove all STANDARD
                                                   code for developm
                                                                        en
                                                   web applications.” t of first class




                                                   Java
                                                    with EJB !!!




BeJUG Evening Session - Enterprise JavaBeans 3.1
Questions?




BeJUG Evening Session - Enterprise JavaBeans 3.1
EJB 3.1 by Bert Ertman

Más contenido relacionado

La actualidad más candente

EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionKelum Senanayake
 
JEE Course - EJB
JEE Course - EJBJEE Course - EJB
JEE Course - EJBodedns
 
Enterprise Java Beans( E)
Enterprise  Java  Beans( E)Enterprise  Java  Beans( E)
Enterprise Java Beans( E)vikram singh
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)Fahad Golra
 
Enterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEnterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEmprovise
 
Entity beans in java
Entity beans in javaEntity beans in java
Entity beans in javaAcp Jamod
 
EJB3 Advance Features
EJB3 Advance FeaturesEJB3 Advance Features
EJB3 Advance FeaturesEmprovise
 
Session 4 Tp4
Session 4 Tp4Session 4 Tp4
Session 4 Tp4phanleson
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkBill Lyons
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Rohit Kelapure
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1phanleson
 
Free EJB Tutorial | VirtualNuggets
Free EJB Tutorial | VirtualNuggetsFree EJB Tutorial | VirtualNuggets
Free EJB Tutorial | VirtualNuggetsVirtual Nuggets
 
EJB Interview Questions
EJB Interview QuestionsEJB Interview Questions
EJB Interview Questionsguest346cb1
 
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 201450 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014Ryan Cuprak
 

La actualidad más candente (20)

EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another Introduction
 
JEE Course - EJB
JEE Course - EJBJEE Course - EJB
JEE Course - EJB
 
Java bean
Java beanJava bean
Java bean
 
Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)
 
EJB 3.0 and J2EE
EJB 3.0 and J2EEEJB 3.0 and J2EE
EJB 3.0 and J2EE
 
Java EE EJB Applications
Java EE EJB ApplicationsJava EE EJB Applications
Java EE EJB Applications
 
Session bean
Session beanSession bean
Session bean
 
Enterprise Java Beans( E)
Enterprise  Java  Beans( E)Enterprise  Java  Beans( E)
Enterprise Java Beans( E)
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)
 
EJB .
EJB .EJB .
EJB .
 
Enterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEnterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business Logic
 
Entity beans in java
Entity beans in javaEntity beans in java
Entity beans in java
 
EJB3 Advance Features
EJB3 Advance FeaturesEJB3 Advance Features
EJB3 Advance Features
 
Session 4 Tp4
Session 4 Tp4Session 4 Tp4
Session 4 Tp4
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLink
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1
 
Free EJB Tutorial | VirtualNuggets
Free EJB Tutorial | VirtualNuggetsFree EJB Tutorial | VirtualNuggets
Free EJB Tutorial | VirtualNuggets
 
EJB Interview Questions
EJB Interview QuestionsEJB Interview Questions
EJB Interview Questions
 
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 201450 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
 

Destacado

Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Eduardo Pelegri-Llopart
 
Java EE and Spring Side-by-Side
Java EE and Spring Side-by-SideJava EE and Spring Side-by-Side
Java EE and Spring Side-by-SideReza Rahman
 
Fun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBFun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBArun Gupta
 
Lightweight J2EE development using Spring
Lightweight J2EE development using SpringLightweight J2EE development using Spring
Lightweight J2EE development using Springspringbyexample
 
jVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginijVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginiSchogini Systems Pvt Ltd
 
Lightweight J2EE development with Spring (special for UADEV)
Lightweight J2EE development with Spring (special for UADEV)Lightweight J2EE development with Spring (special for UADEV)
Lightweight J2EE development with Spring (special for UADEV)springbyexample
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafkamarius_bogoevici
 

Destacado (8)

Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208
 
Java EE and Spring Side-by-Side
Java EE and Spring Side-by-SideJava EE and Spring Side-by-Side
Java EE and Spring Side-by-Side
 
Fun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBFun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJB
 
Lightweight J2EE development using Spring
Lightweight J2EE development using SpringLightweight J2EE development using Spring
Lightweight J2EE development using Spring
 
jVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginijVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by Schogini
 
Lightweight J2EE development with Spring (special for UADEV)
Lightweight J2EE development with Spring (special for UADEV)Lightweight J2EE development with Spring (special for UADEV)
Lightweight J2EE development with Spring (special for UADEV)
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafka
 
Tu1 1 5l
Tu1 1 5lTu1 1 5l
Tu1 1 5l
 

Similar a EJB 3.1 by Bert Ertman

The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologySimon Ritter
 
Enterprise beans
Enterprise beansEnterprise beans
Enterprise beansvpulec
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewEugene Bogaart
 
JBUG.be EJB3 Why use Spring?
JBUG.be EJB3 Why use Spring?JBUG.be EJB3 Why use Spring?
JBUG.be EJB3 Why use Spring?Andries Inzé
 
Connecting ejb with mule
Connecting ejb with muleConnecting ejb with mule
Connecting ejb with muleRuman Khan
 
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-finalRohit Kelapure
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Arun Gupta
 
Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Agora Group
 
Real world java_ee_patterns
Real world java_ee_patternsReal world java_ee_patterns
Real world java_ee_patternsAlassane Diallo
 
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Arun Gupta
 
Introduction to Java EE EJB Component
Introduction to Java EE EJB ComponentIntroduction to Java EE EJB Component
Introduction to Java EE EJB ComponentGanesh P
 

Similar a EJB 3.1 by Bert Ertman (20)

The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
 
Enterprise beans
Enterprise beansEnterprise beans
Enterprise beans
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 Overview
 
Unite5-EJB-2019.ppt
Unite5-EJB-2019.pptUnite5-EJB-2019.ppt
Unite5-EJB-2019.ppt
 
JBUG.be EJB3 Why use Spring?
JBUG.be EJB3 Why use Spring?JBUG.be EJB3 Why use Spring?
JBUG.be EJB3 Why use Spring?
 
J2EE Online Training
J2EE Online TrainingJ2EE Online Training
J2EE Online Training
 
Ch4 ejb
Ch4 ejbCh4 ejb
Ch4 ejb
 
Connecting ejb with mule
Connecting ejb with muleConnecting ejb with mule
Connecting ejb with mule
 
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
 
Virtual classroom
Virtual classroomVirtual classroom
Virtual classroom
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011
 
Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011
 
Real world java_ee_patterns
Real world java_ee_patternsReal world java_ee_patterns
Real world java_ee_patterns
 
Ejb (1)
Ejb (1)Ejb (1)
Ejb (1)
 
Introcution to EJB
Introcution to EJBIntrocution to EJB
Introcution to EJB
 
Java EE6 Overview
Java EE6 OverviewJava EE6 Overview
Java EE6 Overview
 
Java EE 6
Java EE 6Java EE 6
Java EE 6
 
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
 
Introduction to Java EE EJB Component
Introduction to Java EE EJB ComponentIntroduction to Java EE EJB Component
Introduction to Java EE EJB Component
 
Java E
Java EJava E
Java E
 

Más de Stephan Janssen

Devoxx speaker training (June 27th, 2018)
Devoxx speaker training (June 27th, 2018)Devoxx speaker training (June 27th, 2018)
Devoxx speaker training (June 27th, 2018)Stephan Janssen
 
The new DeVoxxEd websites with JHipster, Angular & Kubernetes
The new DeVoxxEd websites with JHipster, Angular & KubernetesThe new DeVoxxEd websites with JHipster, Angular & Kubernetes
The new DeVoxxEd websites with JHipster, Angular & KubernetesStephan Janssen
 
The new Voxxed websites with JHipster, Angular and GitLab
The new Voxxed websites  with JHipster, Angular and GitLabThe new Voxxed websites  with JHipster, Angular and GitLab
The new Voxxed websites with JHipster, Angular and GitLabStephan Janssen
 
Devoxx2011 timesheet day3-4-5
Devoxx2011 timesheet day3-4-5Devoxx2011 timesheet day3-4-5
Devoxx2011 timesheet day3-4-5Stephan Janssen
 
Devoxx2011 timesheet day1-2
Devoxx2011 timesheet day1-2Devoxx2011 timesheet day1-2
Devoxx2011 timesheet day1-2Stephan Janssen
 

Más de Stephan Janssen (17)

Devoxx speaker training (June 27th, 2018)
Devoxx speaker training (June 27th, 2018)Devoxx speaker training (June 27th, 2018)
Devoxx speaker training (June 27th, 2018)
 
The new DeVoxxEd websites with JHipster, Angular & Kubernetes
The new DeVoxxEd websites with JHipster, Angular & KubernetesThe new DeVoxxEd websites with JHipster, Angular & Kubernetes
The new DeVoxxEd websites with JHipster, Angular & Kubernetes
 
The new Voxxed websites with JHipster, Angular and GitLab
The new Voxxed websites  with JHipster, Angular and GitLabThe new Voxxed websites  with JHipster, Angular and GitLab
The new Voxxed websites with JHipster, Angular and GitLab
 
Java, what's next?
Java, what's next?Java, what's next?
Java, what's next?
 
Programming 4 kids
Programming 4 kidsProgramming 4 kids
Programming 4 kids
 
Devoxx2011 timesheet day3-4-5
Devoxx2011 timesheet day3-4-5Devoxx2011 timesheet day3-4-5
Devoxx2011 timesheet day3-4-5
 
Devoxx2011 timesheet day1-2
Devoxx2011 timesheet day1-2Devoxx2011 timesheet day1-2
Devoxx2011 timesheet day1-2
 
BeJUG JAX-RS Event
BeJUG JAX-RS EventBeJUG JAX-RS Event
BeJUG JAX-RS Event
 
Whats New In Java Ee 6
Whats New In Java Ee 6Whats New In Java Ee 6
Whats New In Java Ee 6
 
Glass Fishv3 March2010
Glass Fishv3 March2010Glass Fishv3 March2010
Glass Fishv3 March2010
 
Advanced Scrum
Advanced ScrumAdvanced Scrum
Advanced Scrum
 
Scala by Luc Duponcheel
Scala by Luc DuponcheelScala by Luc Duponcheel
Scala by Luc Duponcheel
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
 
Kick Start Jpa
Kick Start JpaKick Start Jpa
Kick Start Jpa
 
BeJUG - Di With Spring
BeJUG - Di With SpringBeJUG - Di With Spring
BeJUG - Di With Spring
 
BeJUG - Spring 3 talk
BeJUG - Spring 3 talkBeJUG - Spring 3 talk
BeJUG - Spring 3 talk
 
BeJug.Org Java Generics
BeJug.Org   Java GenericsBeJug.Org   Java Generics
BeJug.Org Java Generics
 

Último

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Último (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

EJB 3.1 by Bert Ertman

  • 1. Enterprise JavaBeans 3.1 Bert Ertman berte@infosupport.com
  • 2. Enterprise JavaBeans 3.1 Bert  Ertman Technology  Manager Competence  Center  Java Co-­‐lead  NLJUG,  Sun/Oracle  recognized  Java  Champion Author  and  editorial  board  member   for  Dutch  Java  Magazine E-­‐mail:  berte@infosupport.com Follow  me  on  TwiLer:  @BertErtman
  • 3. J2EE #fail #fail EJB #fail
  • 4.
  • 5. BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 6. Agenda • EJB 3: short recap • What’s new in EJB 3.1 • Ease-of-use improvements • EJB Lite • New features BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 7. The 3 minutes introduction to EJB 3 BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 8. Example: EJB 2.x Session Bean BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 9. Example: EJB 2.x Deployment Descriptor BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 10. Example: EJB 2.x Client View BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 11. blissful ignorance or painful truth of reality? BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 12. Example: EJB 3.x Session Bean BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 13. Example: EJB 3.x Deployment Descriptor BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 14. Example: EJB 3.x Client View BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 15. How did they do that? • Configuration by exception with sensible defaults • Transaction type defaults to CONTAINER • Transaction attribute defaults to REQUIRED • Security permissions defaults to UNCHECKED • Use Annotations • To choose explicitly (recommended) • To override defaults • Deployment descriptor is no longer required • But can override above configurations BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 16. EJB 3 Programming Model 2. Invokes middleware services: Lifecycle mgmt, trx mgmt, Persistence, security, etc. 1. Call a method 4. Return from call 3. Invoke corresponding method on bean class 4. Return outcome BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 17. So, what’s new in EJB 3.1? BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 18. EJB 3.1 • Separate JSR (318) • Evolve separately from JPA • Focus on ease-of-use • Expert group formed - Aug 2007 • Final release - December 2009 BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 19. Ease-of-use improvements • Optional Local Business interface • Simplified packaging • EJB-Lite • Portable JNDI names • Simple component testing BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 20. Example: Session Bean with Local Business interface BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 21. Example: Session Bean without Local Business interface BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 22. Simplified packaging • Goal is to remove artificial packaging restrictions • All resources are shared within .war • Web application APIs are not exposed to EJB components • ejb-jar.xml is still optional • If needed, placed in WEB-INF BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 23. Java EE 5 packaging BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 24. Simplified packaging BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 25. EJB 3.1 lite BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 26. EJB 3.1 “Lite” • Small subset of EJB 3.1 API required by Java EE 6 Web Profile • Broadens the availability of EJB technology without losing portability BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 27. Specs are ok: Blond hair, blue eyes, red lips, EJB HEAVY pink thong... BUT... EJB lite BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 28. Lite vs Full • EJB Lite: • Full = Lite + ... • Local Session Beans • Message Driven Beans • CMT / BMT • EJB Web Service Endpoints • Declarative Security • Interceptors • RMI-IIOP Interop • Web Profile also includes • 2.x / 3.x Remote view JPA 2.0 • 2.x Local view • Timer Service • CMP / BMP Entities BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 29. Portable global JNDI names • Spec-defined lookup names for Remote and Local session beans • Three main goals : • Simplify intra-application Local Session lookups • Simplify mapping of cross-application Remote session bean dependencies • Improve portability of Remote Java clients BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 30. Portable naming syntax • Each session bean gets the following entries : • 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> BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 31. Example: remote session bean with remote client Bean deployed as part of hello.jar BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 32. EJB component testing • Session Beans were always hard to test • Unit-testing was possible, but what about container resources? • Automated integration testing required • Now supported with in-process EJB container BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 33. 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, ... • “Single Application” model • Only required to support 3.1 “Lite” API • Vendors can optionally support additional functionality BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 34. Example: Embeddable API BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 35. New features • Singletons • Startup / shutdown callbacks • Calendar-based timers / automatic timer creation • Asynchronous invocations • JAX-RS integration BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 36. Singletons • One instance per application, per JVM • Not intended to provide cluster-wide singleton • Fits into existing dependency injection architecture • Access through @EJB or lookup • Intended for sharing data within entire application (not just EJB components) • Designed for concurrent access BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 37. Lifecycle of a singleton session bean Does not exist Class.newInstance() @PreDestroy Dependency injections @PostConstruct Method-ready Business method BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 38. Example: simple singleton usage BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 39. Singleton concurrency options • Single threaded (default) • For consistency with all existing bean types • Container Managed Concurrency • Control access via method-level locking metadata • Bean Managed Concurrency • All concurrent invocations have access to bean instance BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 40. Container Managed Concurrency • Concurrent access determined by method- level locking metadata • READ lock: allow any number of concurrent accesses to bean instance • WRITE lock (default): ensure single-threaded bean instance access • Incoming invocations are blocked by container until the necessary lock can be acquired • … or until an optional timeout has been reached BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 41. Example: read-only singleton (container managed) BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 42. Example: read-mostly singleton (container managed) BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 43. Bean Managed Concurrency • All incoming invocations allowed to access bean instance concurrently • Bean developer is solely responsible for maintaining integrity of instance state • Can use synchronization primitives such as synchronized, volatile BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 44. Example: bean managed concurrency BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 45. Application Startup/shutdown callbacks • Uses singleton bean life cycle • Full container services available • Container-managed transactions • Entity Managers, Timer Service, etc. • Startup callback: • @Startup and @PostConstruct • Shutdown callback: • @PreDestroy BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 46. Example: startup/shutdown callbacks BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 47. Timer Service enhancements • Calendar-based timeouts • Automatic timer creation • Non-persistent timers BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 48. Example: EJB 3.0 use of Timer Service BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 49. Some (hard) lessons learned... • Difficult to configure calendar-based events using only relative time units • How to register the timer in the first place? • Typical container events not a great fit; they happen every time application initializes and in every server instance • Burden is on developer to figure out if timer already exists • No way to guarantee that only one is created per cluster BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 50. Calendar based timeouts • Cron-like semantics with improved syntax • Can be created programmatically or automatically • Named attributes: • second, minute, hour (default = “0”) • dayOfMonth, month, dayOfWeek, year (default = “*”) • Relative to optionally specified time zone BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 51. Calendar expression examples • The last Thursday in November at 2 pm: • (hour=”14”, dayOfMonth=”Last Thu”, month=”Nov”) • Every day at 3:15 am U.S. Eastern Time: • (minute=”15”, hour=”3”, timezone=”America/New_York”) • Every twenty seconds: • (second=”*/20”, minute=”*”, hour=”*”) BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 52. Automatic Timer creation • Container creates timer automatically when application is being deployed: BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 53. Example: non-persistent timers BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 54. Simple asynchronous operations • Use metadata to mark a Local/Remote business method as asynchronous • Container returns control to client before executing business method • No separate API to learn BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 55. Example: local concurrent computation BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 56. Asynchronous results • Based on java.util.concurrent.Future • Result value is returned via Future.get() • Also supports Future.get(long, TimeUnit) • Client exception wrapped by ExecutionException • getCause() returns same exception as would have been thrown by a synchronous invocation BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 57. Example: Asynchronous operation result AsyncResult<V> implements Future<V> BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 58. JAX-RS support • Java API for XML RESTful Services • JSR-311 annotations can be used within Stateless Session Beans BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 59. Example: Session Bean as JAX-RS resource BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 60. Rod, I am your father
  • 61. Spring vs Java EE 6 “Now that Java EE 6 is here…do I still need those proprietary frameworks?” Lean Java EE 6 without Spring “Java EE 6 provides similar benefits without tying you to a non-standard solution”
  • 62. BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 63. Soon, in a store near you... Bert Ertman “I wrote this book for developers who ha architects and ve grown increasin frustrated with that gly annoying rebel framework called Sp you can do to impl ring. It shows what ement cleaner, m productive and ab ore ove all STANDARD code for developm en web applications.” t of first class Java with EJB !!! BeJUG Evening Session - Enterprise JavaBeans 3.1
  • 64. Questions? BeJUG Evening Session - Enterprise JavaBeans 3.1