SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
<Insert Picture Here>




What's New in Enterprise JavaBean Technology ?
Sanjeeb Sahoo
Sr. Staff Engineer, Sun, an Oracle Company
The following/preceding is intended to outline our
general product direction. It is intended for
information purposes only, and may not be
incorporated into any contract. It is not a
commitment to deliver any material, code, or
functionality, and should not be relied upon in
making purchasing decisions.
The development, release, and timing of any
features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.



                                                     2
Agenda


• Introduction               <Insert Picture Here>


• Ease of Use Improvements
• New Functionality




                                               3
EJB 3.0 Specification

• Goal
  • Ease of use
  • Developer productivity

• JSR (Java Specification Request) 220
   • Final Specification – 2006




                                         4
EJB 3.0 Specification

• Metadata via Java annotations
  • Only annotations
  • Only XML DD
  • Both
• Sensible defaults
• POJO friendly
• Simplification of bean types
• No home interface
• Interceptors
• Entity Beans replaced by JPA


                                  5
EJB 3.1 Specification

• Goals
   • Continued focus on ease-of-use
   • New features
• JSR (Java Specification Request) 318
   • Final Specification – December 2009




                                           6
Ease of Use Improvements

• Optional Local Business Interfaces
• Simplified Packaging
• EJB 3.1 “Lite” API
• Portable Global JNDI Names
• Simple Component Testing




                                       7
Session Bean
With “No-interface” View




@Stateless
public class GreetingBean {

    public String greet(String msg) {
        return “Hello “ + msg;
    }
}




                                        8
No-interface View Client


@EJB GreetingBean h;

...

h.greet(“bob”);




                           9
Session Bean
“Interface” View

@Stateless
public class HelloBean implements GreetingBean {
    public String greet(String msg) {
        return “Hello “ + msg;
    }
}


@Stateless
public class HowdyBean implements GreetingBean {
    public String greet(String msg) {
        return “Howdy “ + msg;
    }
}

                                               10
Interface View Client


@EJB(beanName=”HelloBean”) GreetingBean h;
h.greet(“bob”);



@EJB(beanName=”HowdyBean”) GreetingBean h2;
h2.greet(“sam”);




                                              11
JavaTM EE Platform 5 Packaging

        foo.ear                         foo.ear

foo_web.war                      lib/foo_common.jar
                                 com/acme/Foo.class
WEB-INF/web.xml
WEB-INF/classes/
 com/acme/FooServlet.class       foo_web.war
 com/acme/Foo.class
                             O   WEB-INF/web.xml
                                 WEB-INF/classes/
foo_ejb.jar                  R   com/acme/FooServlet.class

com/acme/FooBean.class           foo_ejb.jar
com/acme/Foo.class
                                 com/acme/FooBean.class




                                                             12
Simplified Packaging



               foo.war
        WEB-INF/classes/com/acme/
         FooServlet.class
         FooBean.class




                                    13
EJB 3.1 “Lite”




                 14
Portable EJB JNDI Names

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>



                                                 15
Session Bean

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

If deployed as hello.jar, JNDI entries are:

java:global/hello/HelloBean
java:app/hello/HelloBean
java:module/HelloBean




                                              16
Simple Testing : Session Bean

@Stateless
@Local(Bank.class)
public class BankBean implements Bank {

 @PersistenceContext EntityManager accountDB;

 public String createAccount(AcctDetails d)
     { … }

 public void removeAccount(String acctID)

     { … }




                                                17
Embeddable API


public class BankTester {
  public static void main(String[] args) {

   EJBContainer container =
      EJBContainer.createEJBContainer();

   // Acquire Local EJB reference
   Bank bank = (Bank) container.getContext().
     lookup(“java:global/bank/BankBean”);

   testAccountCreation(bank);
       container.close();




                                                18
Test Client Execution


% java -classpath bankClient.jar :
                  bank.jar :
                  javaee.jar :
                  <vendor_rt>.jar

                  com.acme.BankTester




                                        19
New Features

• Singletons
• Startup / Shutdown callbacks
• Automatic timer creation
  • Cron-like syntax
• Asynchronous session bean invocations




                                          20
Singleton

@Singleton
public class SharedBean {

 private SharedData shared;

 @PostConstruct
 private void init() {
   shared = ...;
 }

 public int getXYZ() {
   return shared.xyz;
 }




                              21
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




                                                               22
Startup / Shutdown Callbacks

@Singleton
@Startup
public class StartupBean {

    @PostConstruct
    private void onStartup() { … }

    @PreDestroy
    private void onShutdown() { … }

}




                                      23
Timers

• Automatically created EJB Timers
• Calendar-based Timers – cron like semantics
 • Every Mon & Wed midnight
   @Schedule(dayOfWeek=”Mon,Wed”)
 • 2pm on Last Thur of Nov of every year
   (hour=”14”, dayOfMonth=”Last Thu”,
   month=”Nov”)
 • Every 5 minutes of every hour
   (minute=”*/5”, hour=”*”)
 • Every 10 seconds starting at 30
   (second=”30/10”)
 • Every 14th minute within the hour, for the hours 1 and 2 am
   (minute=”*/14”, hour=”1,2”)
                                                            24
Automatic Timer Creation

@Stateless
public class BankBean {

    @PersistenceContext EntityManager accountDB;
    @Resource javax.mail.Session mailSession;

    // Callback the last day of each month at 8 a.m.

    @Schedule(hour=”8”, dayOfMonth=”Last”)
    void sendMonthlyBankStatements() {
      ...
    }
}




                                                       25
Asynchronous Session Beans
• Control returns to the client before the container
      dispatches invocation to a bean instance
•   @Asynchronous – method or class
•   Return type – void or Future<V>
•   “Fire and and Forget” or async results via
      Future<V>
•   Best effort delivery – persistent delivery
      guarantees are not required by spec
•   Transaction context does not propagate
    • REQUIRED → REQUIRED_NEW
• Security principal propagates
                                                       26
Asynchronous Session Beans
Code Sample
@Stateless
@Asynchronous
public class SimpleAsyncEJB {
    public Future<Integer> addNumbers(int n1, int n2) {
        Integer result;

            result = n1 + n2;
            try {
                // simulate JPA queries + reading file system
                Thread.currentThread().sleep(2000);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }

            return new AsyncResult(result);
      }
}



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


                                                                   27
References


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




                                28

Contenu connexe

Tendances

Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBHiro Asari
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, mavenFahad Golra
 
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 201450 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014Arun Gupta
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: ServletsFahad Golra
 
50 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 201450 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 2014Arun Gupta
 
Intsllation & 1st program nodejs
Intsllation & 1st program nodejsIntsllation & 1st program nodejs
Intsllation & 1st program nodejsmonikadeshmane
 
Introduction to OSGi (Tokyo JUG)
Introduction to OSGi (Tokyo JUG)Introduction to OSGi (Tokyo JUG)
Introduction to OSGi (Tokyo JUG)njbartlett
 
50 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 201450 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 2014Arun Gupta
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modulesmonikadeshmane
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Saeed Zarinfam
 
Gilt Groupe's Selenium 2 Conversion Challenges
Gilt Groupe's Selenium 2 Conversion ChallengesGilt Groupe's Selenium 2 Conversion Challenges
Gilt Groupe's Selenium 2 Conversion ChallengesSauce Labs
 
Puppet Camp London 2014: MCollective as an Integration Layer
Puppet Camp London 2014: MCollective as an Integration LayerPuppet Camp London 2014: MCollective as an Integration Layer
Puppet Camp London 2014: MCollective as an Integration LayerPuppet
 
Spring 3.1 in a Nutshell
Spring 3.1 in a NutshellSpring 3.1 in a Nutshell
Spring 3.1 in a NutshellSam Brannen
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to ProtractorJie-Wei Wu
 
Java EE 7 - Into the Cloud
Java EE 7 - Into the CloudJava EE 7 - Into the Cloud
Java EE 7 - Into the CloudMarkus Eisele
 
Java Unit Testing with Unitils
Java Unit Testing with UnitilsJava Unit Testing with Unitils
Java Unit Testing with UnitilsMikalai Alimenkou
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 

Tendances (20)

EJB 3.1 and GlassFish v3 Prelude
EJB 3.1 and GlassFish v3 PreludeEJB 3.1 and GlassFish v3 Prelude
EJB 3.1 and GlassFish v3 Prelude
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
 
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 201450 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: Servlets
 
50 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 201450 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 2014
 
Java Servlet
Java Servlet Java Servlet
Java Servlet
 
Intsllation & 1st program nodejs
Intsllation & 1st program nodejsIntsllation & 1st program nodejs
Intsllation & 1st program nodejs
 
Introduction to OSGi (Tokyo JUG)
Introduction to OSGi (Tokyo JUG)Introduction to OSGi (Tokyo JUG)
Introduction to OSGi (Tokyo JUG)
 
50 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 201450 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 2014
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modules
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
 
Gilt Groupe's Selenium 2 Conversion Challenges
Gilt Groupe's Selenium 2 Conversion ChallengesGilt Groupe's Selenium 2 Conversion Challenges
Gilt Groupe's Selenium 2 Conversion Challenges
 
Puppet Camp London 2014: MCollective as an Integration Layer
Puppet Camp London 2014: MCollective as an Integration LayerPuppet Camp London 2014: MCollective as an Integration Layer
Puppet Camp London 2014: MCollective as an Integration Layer
 
Spring 3.1 in a Nutshell
Spring 3.1 in a NutshellSpring 3.1 in a Nutshell
Spring 3.1 in a Nutshell
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
Java EE 7 - Into the Cloud
Java EE 7 - Into the CloudJava EE 7 - Into the Cloud
Java EE 7 - Into the Cloud
 
Java Unit Testing with Unitils
Java Unit Testing with UnitilsJava Unit Testing with Unitils
Java Unit Testing with Unitils
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 

Similaire à What's New in Enterprise JavaBean Technology ?

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
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 
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
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
Micronaut Deep Dive - Devnexus 2019
Micronaut Deep Dive - Devnexus 2019Micronaut Deep Dive - Devnexus 2019
Micronaut Deep Dive - Devnexus 2019graemerocher
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7Deniz Oguz
 
Skillwise EJB3.0 training
Skillwise EJB3.0 trainingSkillwise EJB3.0 training
Skillwise EJB3.0 trainingSkillwise Group
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Rittercatherinewall
 
Java EE web project introduction
Java EE web project introductionJava EE web project introduction
Java EE web project introductionOndrej Mihályi
 
J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical OverviewSvetlin Nakov
 
The Java EE 6 platform
The Java EE 6 platformThe Java EE 6 platform
The Java EE 6 platformLorraine JUG
 
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
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Martijn Verburg
 
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGOverview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGMarakana Inc.
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 

Similaire à What's New in Enterprise JavaBean Technology ? (20)

Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
 
Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Micronaut Deep Dive - Devnexus 2019
Micronaut Deep Dive - Devnexus 2019Micronaut Deep Dive - Devnexus 2019
Micronaut Deep Dive - Devnexus 2019
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
Skillwise EJB3.0 training
Skillwise EJB3.0 trainingSkillwise EJB3.0 training
Skillwise EJB3.0 training
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Ritter
 
J2 Ee Overview
J2 Ee OverviewJ2 Ee Overview
J2 Ee Overview
 
Java EE web project introduction
Java EE web project introductionJava EE web project introduction
Java EE web project introduction
 
J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical Overview
 
The Java EE 6 platform
The Java EE 6 platformThe Java EE 6 platform
The Java EE 6 platform
 
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
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
Ejb examples
Ejb examplesEjb examples
Ejb examples
 
Best Of Jdk 7
Best Of Jdk 7Best Of Jdk 7
Best Of Jdk 7
 
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGOverview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUG
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 

Dernier

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - 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
 
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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
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
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Dernier (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - 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
 
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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
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
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

What's New in Enterprise JavaBean Technology ?

  • 1. <Insert Picture Here> What's New in Enterprise JavaBean Technology ? Sanjeeb Sahoo Sr. Staff Engineer, Sun, an Oracle Company
  • 2. The following/preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 2
  • 3. Agenda • Introduction <Insert Picture Here> • Ease of Use Improvements • New Functionality 3
  • 4. EJB 3.0 Specification • Goal • Ease of use • Developer productivity • JSR (Java Specification Request) 220 • Final Specification – 2006 4
  • 5. EJB 3.0 Specification • Metadata via Java annotations • Only annotations • Only XML DD • Both • Sensible defaults • POJO friendly • Simplification of bean types • No home interface • Interceptors • Entity Beans replaced by JPA 5
  • 6. EJB 3.1 Specification • Goals • Continued focus on ease-of-use • New features • JSR (Java Specification Request) 318 • Final Specification – December 2009 6
  • 7. Ease of Use Improvements • Optional Local Business Interfaces • Simplified Packaging • EJB 3.1 “Lite” API • Portable Global JNDI Names • Simple Component Testing 7
  • 8. Session Bean With “No-interface” View @Stateless public class GreetingBean { public String greet(String msg) { return “Hello “ + msg; } } 8
  • 9. No-interface View Client @EJB GreetingBean h; ... h.greet(“bob”); 9
  • 10. Session Bean “Interface” View @Stateless public class HelloBean implements GreetingBean { public String greet(String msg) { return “Hello “ + msg; } } @Stateless public class HowdyBean implements GreetingBean { public String greet(String msg) { return “Howdy “ + msg; } } 10
  • 11. Interface View Client @EJB(beanName=”HelloBean”) GreetingBean h; h.greet(“bob”); @EJB(beanName=”HowdyBean”) GreetingBean h2; h2.greet(“sam”); 11
  • 12. JavaTM EE Platform 5 Packaging foo.ear foo.ear foo_web.war lib/foo_common.jar com/acme/Foo.class WEB-INF/web.xml WEB-INF/classes/ com/acme/FooServlet.class foo_web.war com/acme/Foo.class O WEB-INF/web.xml WEB-INF/classes/ foo_ejb.jar R com/acme/FooServlet.class com/acme/FooBean.class foo_ejb.jar com/acme/Foo.class com/acme/FooBean.class 12
  • 13. Simplified Packaging foo.war WEB-INF/classes/com/acme/ FooServlet.class FooBean.class 13
  • 15. Portable EJB JNDI Names 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> 15
  • 16. Session Bean @Stateless public class HelloBean implements Hello { public String sayHello(String msg) { return “Hello “ + msg; } } If deployed as hello.jar, JNDI entries are: java:global/hello/HelloBean java:app/hello/HelloBean java:module/HelloBean 16
  • 17. Simple Testing : Session Bean @Stateless @Local(Bank.class) public class BankBean implements Bank { @PersistenceContext EntityManager accountDB; public String createAccount(AcctDetails d) { … } public void removeAccount(String acctID) { … } 17
  • 18. Embeddable API public class BankTester { public static void main(String[] args) { EJBContainer container = EJBContainer.createEJBContainer(); // Acquire Local EJB reference Bank bank = (Bank) container.getContext(). lookup(“java:global/bank/BankBean”); testAccountCreation(bank); container.close(); 18
  • 19. Test Client Execution % java -classpath bankClient.jar : bank.jar : javaee.jar : <vendor_rt>.jar com.acme.BankTester 19
  • 20. New Features • Singletons • Startup / Shutdown callbacks • Automatic timer creation • Cron-like syntax • Asynchronous session bean invocations 20
  • 21. Singleton @Singleton public class SharedBean { private SharedData shared; @PostConstruct private void init() { shared = ...; } public int getXYZ() { return shared.xyz; } 21
  • 22. 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 22
  • 23. Startup / Shutdown Callbacks @Singleton @Startup public class StartupBean { @PostConstruct private void onStartup() { … } @PreDestroy private void onShutdown() { … } } 23
  • 24. Timers • Automatically created EJB Timers • Calendar-based Timers – cron like semantics • Every Mon & Wed midnight @Schedule(dayOfWeek=”Mon,Wed”) • 2pm on Last Thur of Nov of every year (hour=”14”, dayOfMonth=”Last Thu”, month=”Nov”) • Every 5 minutes of every hour (minute=”*/5”, hour=”*”) • Every 10 seconds starting at 30 (second=”30/10”) • Every 14th minute within the hour, for the hours 1 and 2 am (minute=”*/14”, hour=”1,2”) 24
  • 25. Automatic Timer Creation @Stateless public class BankBean { @PersistenceContext EntityManager accountDB; @Resource javax.mail.Session mailSession; // Callback the last day of each month at 8 a.m. @Schedule(hour=”8”, dayOfMonth=”Last”) void sendMonthlyBankStatements() { ... } } 25
  • 26. Asynchronous Session Beans • Control returns to the client before the container dispatches invocation to a bean instance • @Asynchronous – method or class • Return type – void or Future<V> • “Fire and and Forget” or async results via Future<V> • Best effort delivery – persistent delivery guarantees are not required by spec • Transaction context does not propagate • REQUIRED → REQUIRED_NEW • Security principal propagates 26
  • 27. Asynchronous Session Beans Code Sample @Stateless @Asynchronous public class SimpleAsyncEJB { public Future<Integer> addNumbers(int n1, int n2) { Integer result; result = n1 + n2; try { // simulate JPA queries + reading file system Thread.currentThread().sleep(2000); } catch (InterruptedException ex) { ex.printStackTrace(); } return new AsyncResult(result); } } http://blogs.sun.com/arungupta/entry/totd_137_asynchronous_ejb_a 27
  • 28. References • oracle.com/javaee • glassfish.org • oracle.com/goto/glassfish • blogs.sun.com/theaquarium • youtube.com/GlassFishVideos • Follow @glassfish 28