SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
Whats new in EJB 3.1?
                             a.k.a
                 How do I convert
      my POJOs to EJBs with JEE6
What I'm gonna talk about
●   What is EJB 3.1
●   Whats new on EJB 3.1
●   Types of EJB 3.1
    –   Stateless
    –   Stateful
    –   Singleton
●   Other aspects of EJB 3.1
    –   Injecting beans in to another EJB
    –   Exposing EJB as REST
●   Unit testing EJB
What this session is NOT about
●   Full JEE6 stack
●   Persistence with EJB
●   Transactions
●   JMS
●   NOT about EJB but you I ll let u know about
    EJB ;-)
What is EJB 3.1
●   A whole new simplified way of developing enterprise
    applications which follows JEE specification.
●   “whole new simplified” -> just POJO no framework
    specific API needs to extended or realized always.

    EJB == JB
    (the “E” factor is taken care by the container)
●   Unit test without pain !!
Whats new on EJB 3.1
●   Requires NO framework specific API to be
    extended or realized
●   Efficient use of Annotations for developing beans
●   No vendor specific deployment descriptors needed
●   New annotations to develop beans such as
    –   Singleton
    –   Startup
    –   Timer & schedule expressions
    –   Exposing EJB as REST services
Stateless Bean
public class CalculatorBean {
    public int add(int a, int b) {
        return a + b;
    }
    public int subtract(int a, int b) {
        return a - b;
    }
}
Stateless Bean
@stateless
public class CalculatorBean {
    public int add(int a, int b) {
        return a + b;
    }
    public int subtract(int a, int b) {
        return a - b;
    }
}
Stateful Beans
public class Counter {
    private int count = 0;
    public int count() {
        return count;
    }
    public int increment() {
        return ++count;
    }
}
Stateful Beans
@stateful
public class Counter {
    private int count = 0;
    public int count() {
        return count;
    }
    public int increment() {
        return ++count;
    }
}
Singleton Beans
@singleton
public class PropertyRegistry {
    private final Properties properties = new Properties();
    public String getProperty(String key) {
        return properties.getProperty(key);
    }
    public String setProperty(String key, String value) {
        return (String) properties.setProperty(key, value);
    }
    public String removeProperty(String key) {
        return (String) properties.remove(key);
    }
}
Bootstrapping Beans on “startup”
@singleton
@startup
public class PropertyRegistry {
    private final Properties properties = new Properties();
    public String getProperty(String key) {
        return properties.getProperty(key);
    }
    public String setProperty(String key, String value) {
        return (String) properties.setProperty(key, value);
    }
    public String removeProperty(String key) {
        return (String) properties.remove(key);
    }
}
Injecting EJB to another
@stateless
public class AuthenticationBean {
    @EJB
    private LoginBean loginBean;
    public void doLogin() {
    LoginBean.authenticate();
    // ...
    }
}
Exposing EJB as REST
@Singleton
@Lock(LockType.WRITE)
@Path("/user")
@Produces(MediaType.APPLICATION_XML)
public class UserService {
    @Path("/list")
    @GET
    public List<User> list() {
        // ....
        return users;
    }
}
JUnit tesing EJBs
public class CalculatorTest extends TestCase {
   private CalculatorBean calculator;


   protected void setUp() throws Exception {
       EJBContainer ejbContainer =
EJBContainer.createEJBContainer();
       Object object =
ejbContainer.getContext().lookup("java:global/simple-
stateless/CalculatorBean");
       assertTrue(object instanceof CalculatorBean);
       calculator = (CalculatorBean) object;
   }
   public void testAdd() {
       assertEquals(10, calculator.add(4, 6));
   }

Mais conteúdo relacionado

Mais procurados

Mysql creating stored function
Mysql  creating stored function Mysql  creating stored function
Mysql creating stored function Prof.Nilesh Magar
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvmArnaud Giuliani
 
Kotlin in action
Kotlin in actionKotlin in action
Kotlin in actionCiro Rizzo
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript BasicsMindfire Solutions
 
JavaScript Beyond jQuery
JavaScript Beyond jQueryJavaScript Beyond jQuery
JavaScript Beyond jQueryBobby Bryant
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized军 沈
 
Say Goodbye To Java: Getting Started With Kotlin For Android Development
Say Goodbye To Java: Getting Started With Kotlin For Android DevelopmentSay Goodbye To Java: Getting Started With Kotlin For Android Development
Say Goodbye To Java: Getting Started With Kotlin For Android DevelopmentAdam Magaña
 
Learn You a Frege for Great Good!
Learn You a Frege for Great Good!Learn You a Frege for Great Good!
Learn You a Frege for Great Good!y_taka_23
 
Functional patterns and techniques in C#
Functional patterns and techniques in C#Functional patterns and techniques in C#
Functional patterns and techniques in C#Péter Takács
 
Hipster Oriented Programming
Hipster Oriented ProgrammingHipster Oriented Programming
Hipster Oriented ProgrammingJens Ravens
 
Oop lec 5-(class objects, constructor & destructor)
Oop lec 5-(class objects, constructor & destructor)Oop lec 5-(class objects, constructor & destructor)
Oop lec 5-(class objects, constructor & destructor)Asfand Hassan
 
A quick and fast intro to Kotlin
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin XPeppers
 
Java Serialization
Java SerializationJava Serialization
Java Serializationjeslie
 

Mais procurados (20)

Mysql creating stored function
Mysql  creating stored function Mysql  creating stored function
Mysql creating stored function
 
Seasar Conference 2009 White - DI
Seasar Conference 2009 White - DISeasar Conference 2009 White - DI
Seasar Conference 2009 White - DI
 
Callback Function
Callback FunctionCallback Function
Callback Function
 
Reactjs: Rethinking UI Devel
Reactjs: Rethinking UI DevelReactjs: Rethinking UI Devel
Reactjs: Rethinking UI Devel
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Js: master prototypes
Js: master prototypesJs: master prototypes
Js: master prototypes
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvm
 
Kotlin in action
Kotlin in actionKotlin in action
Kotlin in action
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
JavaScript Beyond jQuery
JavaScript Beyond jQueryJavaScript Beyond jQuery
JavaScript Beyond jQuery
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized
 
Say Goodbye To Java: Getting Started With Kotlin For Android Development
Say Goodbye To Java: Getting Started With Kotlin For Android DevelopmentSay Goodbye To Java: Getting Started With Kotlin For Android Development
Say Goodbye To Java: Getting Started With Kotlin For Android Development
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Learn You a Frege for Great Good!
Learn You a Frege for Great Good!Learn You a Frege for Great Good!
Learn You a Frege for Great Good!
 
Functional patterns and techniques in C#
Functional patterns and techniques in C#Functional patterns and techniques in C#
Functional patterns and techniques in C#
 
Hipster Oriented Programming
Hipster Oriented ProgrammingHipster Oriented Programming
Hipster Oriented Programming
 
Oop lec 5-(class objects, constructor & destructor)
Oop lec 5-(class objects, constructor & destructor)Oop lec 5-(class objects, constructor & destructor)
Oop lec 5-(class objects, constructor & destructor)
 
A quick and fast intro to Kotlin
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin
 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
 

Semelhante a Ejb3.1

Why Spring <3 Kotlin
Why Spring <3 KotlinWhy Spring <3 Kotlin
Why Spring <3 KotlinVMware Tanzu
 
To inject or not to inject: CDI is the question
To inject or not to inject: CDI is the questionTo inject or not to inject: CDI is the question
To inject or not to inject: CDI is the questionAntonio Goncalves
 
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010Arun Gupta
 
What's New in Enterprise JavaBean Technology ?
What's New in Enterprise JavaBean Technology ?What's New in Enterprise JavaBean Technology ?
What's New in Enterprise JavaBean Technology ?Sanjeeb Sahoo
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaDILo Surabaya
 
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Kotlin For Android - Constructors and Control Flow (part 2 of 7)Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Kotlin For Android - Constructors and Control Flow (part 2 of 7)Gesh Markov
 
Software design principles SOLID
Software design principles SOLIDSoftware design principles SOLID
Software design principles SOLIDFoyzul Karim
 
Software Transactioneel Geheugen
Software Transactioneel GeheugenSoftware Transactioneel Geheugen
Software Transactioneel GeheugenDevnology
 
Effective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's bookEffective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's bookRoman Tsypuk
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Mohamed Nabil, MSc.
 
Building Mobile Apps with Android
Building Mobile Apps with AndroidBuilding Mobile Apps with Android
Building Mobile Apps with AndroidKurt Renzo Acosta
 
Боремся с NPE вместе с Kotlin, Павел Шацких СберТех
Боремся с NPE вместе с Kotlin, Павел Шацких СберТехБоремся с NPE вместе с Kotlin, Павел Шацких СберТех
Боремся с NPE вместе с Kotlin, Павел Шацких СберТехСбертех | SberTech
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppteShikshak
 
Journey of a C# developer into Javascript
Journey of a C# developer into JavascriptJourney of a C# developer into Javascript
Journey of a C# developer into JavascriptMassimo Franciosa
 
OO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual FunctionOO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual FunctionYu-Sheng (Yosen) Chen
 
Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"IT Event
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Antoine Sabot-Durand
 

Semelhante a Ejb3.1 (20)

Why Spring <3 Kotlin
Why Spring <3 KotlinWhy Spring <3 Kotlin
Why Spring <3 Kotlin
 
To inject or not to inject: CDI is the question
To inject or not to inject: CDI is the questionTo inject or not to inject: CDI is the question
To inject or not to inject: CDI is the question
 
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
 
What's New in Enterprise JavaBean Technology ?
What's New in Enterprise JavaBean Technology ?What's New in Enterprise JavaBean Technology ?
What's New in Enterprise JavaBean Technology ?
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo Surabaya
 
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Kotlin For Android - Constructors and Control Flow (part 2 of 7)Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
 
Software design principles SOLID
Software design principles SOLIDSoftware design principles SOLID
Software design principles SOLID
 
Software Transactioneel Geheugen
Software Transactioneel GeheugenSoftware Transactioneel Geheugen
Software Transactioneel Geheugen
 
Effective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's bookEffective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's book
 
Class 6 2ciclo
Class 6 2cicloClass 6 2ciclo
Class 6 2ciclo
 
Ejb3 Dan Hinojosa
Ejb3 Dan HinojosaEjb3 Dan Hinojosa
Ejb3 Dan Hinojosa
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
 
Building Mobile Apps with Android
Building Mobile Apps with AndroidBuilding Mobile Apps with Android
Building Mobile Apps with Android
 
Боремся с NPE вместе с Kotlin, Павел Шацких СберТех
Боремся с NPE вместе с Kotlin, Павел Шацких СберТехБоремся с NPE вместе с Kotlin, Павел Шацких СберТех
Боремся с NPE вместе с Kotlin, Павел Шацких СберТех
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppt
 
Journey of a C# developer into Javascript
Journey of a C# developer into JavascriptJourney of a C# developer into Javascript
Journey of a C# developer into Javascript
 
OO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual FunctionOO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual Function
 
Koin Quickstart
Koin QuickstartKoin Quickstart
Koin Quickstart
 
Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
 

Mais de PrasannaKumar Sathyanarayanan (10)

Akka introtalk HyScala DEC 2016
Akka introtalk HyScala DEC 2016Akka introtalk HyScala DEC 2016
Akka introtalk HyScala DEC 2016
 
Akka fsm presentation
Akka fsm presentationAkka fsm presentation
Akka fsm presentation
 
Cps (continuation passing style) in scala
Cps (continuation passing style) in scalaCps (continuation passing style) in scala
Cps (continuation passing style) in scala
 
Introduction to akka chense
Introduction to akka   chenseIntroduction to akka   chense
Introduction to akka chense
 
Finagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvmFinagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvm
 
Websocket,JSON in JEE7
Websocket,JSON in JEE7Websocket,JSON in JEE7
Websocket,JSON in JEE7
 
Scala Introduction with play - for my CSS nerds
Scala Introduction with play - for my CSS nerdsScala Introduction with play - for my CSS nerds
Scala Introduction with play - for my CSS nerds
 
CDI in JEE6
CDI in JEE6CDI in JEE6
CDI in JEE6
 
Producer consumerproblem
Producer consumerproblemProducer consumerproblem
Producer consumerproblem
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
 

Último

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 
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
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
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
 

Último (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
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!
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
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
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
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
 

Ejb3.1

  • 1. Whats new in EJB 3.1? a.k.a How do I convert my POJOs to EJBs with JEE6
  • 2. What I'm gonna talk about ● What is EJB 3.1 ● Whats new on EJB 3.1 ● Types of EJB 3.1 – Stateless – Stateful – Singleton ● Other aspects of EJB 3.1 – Injecting beans in to another EJB – Exposing EJB as REST ● Unit testing EJB
  • 3. What this session is NOT about ● Full JEE6 stack ● Persistence with EJB ● Transactions ● JMS ● NOT about EJB but you I ll let u know about EJB ;-)
  • 4. What is EJB 3.1 ● A whole new simplified way of developing enterprise applications which follows JEE specification. ● “whole new simplified” -> just POJO no framework specific API needs to extended or realized always. EJB == JB (the “E” factor is taken care by the container) ● Unit test without pain !!
  • 5. Whats new on EJB 3.1 ● Requires NO framework specific API to be extended or realized ● Efficient use of Annotations for developing beans ● No vendor specific deployment descriptors needed ● New annotations to develop beans such as – Singleton – Startup – Timer & schedule expressions – Exposing EJB as REST services
  • 6. Stateless Bean public class CalculatorBean { public int add(int a, int b) { return a + b; } public int subtract(int a, int b) { return a - b; } }
  • 7. Stateless Bean @stateless public class CalculatorBean { public int add(int a, int b) { return a + b; } public int subtract(int a, int b) { return a - b; } }
  • 8. Stateful Beans public class Counter { private int count = 0; public int count() { return count; } public int increment() { return ++count; } }
  • 9. Stateful Beans @stateful public class Counter { private int count = 0; public int count() { return count; } public int increment() { return ++count; } }
  • 10. Singleton Beans @singleton public class PropertyRegistry { private final Properties properties = new Properties(); public String getProperty(String key) { return properties.getProperty(key); } public String setProperty(String key, String value) { return (String) properties.setProperty(key, value); } public String removeProperty(String key) { return (String) properties.remove(key); } }
  • 11. Bootstrapping Beans on “startup” @singleton @startup public class PropertyRegistry { private final Properties properties = new Properties(); public String getProperty(String key) { return properties.getProperty(key); } public String setProperty(String key, String value) { return (String) properties.setProperty(key, value); } public String removeProperty(String key) { return (String) properties.remove(key); } }
  • 12. Injecting EJB to another @stateless public class AuthenticationBean { @EJB private LoginBean loginBean; public void doLogin() { LoginBean.authenticate(); // ... } }
  • 13. Exposing EJB as REST @Singleton @Lock(LockType.WRITE) @Path("/user") @Produces(MediaType.APPLICATION_XML) public class UserService { @Path("/list") @GET public List<User> list() { // .... return users; } }
  • 14. JUnit tesing EJBs public class CalculatorTest extends TestCase { private CalculatorBean calculator; protected void setUp() throws Exception { EJBContainer ejbContainer = EJBContainer.createEJBContainer(); Object object = ejbContainer.getContext().lookup("java:global/simple- stateless/CalculatorBean"); assertTrue(object instanceof CalculatorBean); calculator = (CalculatorBean) object; } public void testAdd() { assertEquals(10, calculator.add(4, 6)); }