SlideShare a Scribd company logo
1 of 37
SKILLWISE-EJB3.0
Goal
Learn how EJB 3.0 technology simplifies
Java EE application development
Content
Overview and Background
EJB 3.0 - What’s New ?
EJB 3.0 API
EJB 3.0 Persistence
Compatibility and Migration
Summary
Resources
Agenda
What is EJB?
A server side component architecture for the development
and deployment of distributed, enterprise applications in
Java.
Typically contain the business logic of an enterprise
application
EJB applications are scalable, transactional, multi-user and
secure.
EJB components are managed by the EJB container that is
part of a Java EE server
EJB Architecture
EJB Object
Advantages of EJB
Write Once, Deploy Anywhere
Frees the application developer from having to deal
with the system level aspects of an application.
Behavior can be configured at deployment without
modifying the source code
Rapid and simplified development of distributed,
transactional, secure and portable Java EE applications
Types of EJBs
Session Bean
Stateful Session Bean
Stateless Session Bean
Entity Bean
• Based on persistence types,
Bean managed
Container managed
Message Driven Bean
An EJB 2.1 Example
8
// Bean class
public class HelloBean implements SessionBean {
private SessionContext sessionContext;
public void ejbCreate() { }
public void ejbRemove() { }
public void ejbActivate() { }
public void ejbPassivate() { }
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
public String sayHello() {
return "Hello World!!!!!";
}
}
// Home Interface
public interface HelloHome extends EJBHome {
public Hello create() throws RemoteException, CreateException;
}
// Remote Interface
public interface Hello extends EJBObject {
public String sayHello() throws RemoteException;
}
An EJB 2.1 Example (Contd.)
9
// Entry in ejb-jar.xml (deployment descriptor)
<session>
<ejb-name>Hello</ejb-name>
<home>com.jlive.demo.hello.HelloHome</home>
<remote>com.jlive.demo.hello.Hello</remote>
<ejb-class>com.jlive.demo.hello.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</session>
//Client code
public class HelloClient {
public static void main(String [] args) throws Exception {
Context jndiContext = new InitialContext();
Object ref = jndiContext.lookup("Hello");
HelloHome helloHome = (HelloHome)
PortableRemoteObject.narrow(ref,
HelloHome.class);
Hello hello = helloHome.create();
System.out.println(hello.sayHello());
}
}
What was wrong with EJB 2.1?
EJB 2.1 technology
Very powerful, but complex to use
Too many classes, interfaces
Java Naming and Directory Interface™(JNDI) API lookups
javax.ejb interfaces
Awkward programming model
Deployment descriptors
Entity bean anti-patterns
Difficult to test entities outside the container
EJB 3.0 - What’s New ?
Simplification of the EJB APIs
Utilizes advantages of Java metadata annotations
More work is done by container, less by developer
Dependency injection
New Persistence API Specification
EJB 3.0 Bean Simplification
Elimination of EJB component interfaces
Business interfaces are plain Java interfaces
Elimination of Home interfaces
Only need business interface, not home
Elimination of requirements for
javax.ejb.EnterpriseBean interfaces
Annotations for (optional) callbacks
Elimination of need for use of JNDI API
Use dependency injection, simple lookup method
Example – EJB 3.0
13
// Bean class
@Stateless
public class NewHelloBean implements NewHello{
public String sayHello() {
return "Hello New World!!!!!";
}
}
// Business Interface
@Remote
public interface NewHello {
public String sayHello();
}
// Client code
public class NewHelloClient
{
public static void main(String [] args) throws Exception {
Context jndiContext = new InitialContext();
Object ref = jndiContext.lookup("NewHello");
NewHello hello = (NewHello)ref;
System.out.println(hello.sayHello());
}
}
MDB in EJB 3.0
14
@MessageDriven(activateConfig = {
@ActivationConfigProperty(propertyName="destinationTy
pe", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination",
propertyValue="queue/mdb") })
public class CalculatorBean implements MessageListener {
public void onMessage (Message msg) {
try {
TextMessage tmsg = (TextMessage) msg;
} catch (Exception e) { e.printStackTrace (); } }
// ... ... }
Message driven beans are components designed to handle
message based requests
The MDB must implement the Message Listener interface.
The on Message method is invoked when a message is
received by the container
Resource Injection
Resource injection is an inversion of dependency
Resources can be injected on bean creation
References of
DataSources, UserTransaction, Environment entries,
EntityManager, Other EJB beans
Annotations
@EJB
@Resource
Injection can be specified using deployment descriptor
Resource Injection – EJB 3.0
16
@Resource(name=”myDB”, type=javax.sql.DataSource)
@Stateful public class ShoppingCartBean implements
ShoppingCart {
@Resource SessionContext ctx;
public Collection startToShop (String productName) {
...
DataSource productDB =
(DataSource)ctx.lookup(“myDB”);
Connection conn = myDB.getConnection();
...
}
...
}
Simplified Client View
17
Clients can easily lookup enterprise beans using the @EJB
annotation
Access can be Remote/Local. Remoteness is hidden
// EJB 2.1 Client view of the ShoppingCart bean
...
Context initialContext = new InitialContext();
ShoppingCartHome myCartHome =
(ShoppingCartHome)
initialContext.lookup(“java:comp/env/ejb/cart”);
ShoppingCart myCart= myCartHome.create();
//Use the bean
Collection widgets = myCart.startToShop(“widgets”)
...
// catch javax.ejb.CreateException/javax.ejb.EJBException
• // EJB 3.0 client view
• @EJB ShoppingCart myCart;
• ...
• Collection widgets =
myCart.startToShop(“widgets”);
• ...
EJB 3.0 Transactions
19
CMT by default, BMT by annotation
Specified at class level or method level
Default is CMT + REQUIRED
• // Uses container-managed transaction, REQUIRED attribute
• @Stateless public PayrollBean implements Payroll {
• @TransactionAttribute(MANDATORY)
• public void setBenefitsDeduction(int empId, double
deduction) {...}
• public double getBenefitsDeduction(int empId) {...}
• public double getSalary(int empid) {...}
• @TransactionAttribute(REQUIRES_NEW)
• public void setSalary(int empId, double salary) {...}
• }
EJB 3.0 Security
21
Security configuration preferred at deployment
Annotations - @Unchecked, @RolesAllowed
Default is unchecked
// Security view
@Stateless public PayrollBean implements Payroll {
public void setBenefitsDeduction(int empId, double deduction)
{...}
public double getBenefitsDeduction(int empId) {...}
public double getSalary(int empid) {...}
// salary setting is intended to be more restricted
@RolesAllowed(“HR_PayrollAdministrator”)
public void setSalary(int empId, double salary) {...}
}
EJB 3.0 Callback - Event Notification
22
Container calls bean upon lifecycle events
@PostConstruct, @PreDestroy, @PrePassivate, @PostActivate,…
Bean specifies events it needs to know about
Callback methods can be specified on lifecycle listener
23
EJB 3.0 Interceptors
Interception of invocations of business methods and/or
message listener methods
Invocation model: “around” methods
Wrapped around business method invocations
Interceptor has control over invocation of “next method”
Can manipulate arguments and results
Context data can be carried across invocation chain
Execute in specified order
Can use deployment descriptor to override order or add
interceptors
Annotations
 @Interceptors, @AroundInvoke
EJB 3.0 Interceptors - Example
25
@Interceptors({
com.demo.AuditInterceptor.class,
com.demo.LoggerInterceptor.class
})
@Stateless
public class AccountManagementBean implements
AccountManagement {
public void createAccount(int accountId, Details
details) {...}
public void deleteAccount(int accountId) {...}
}
public class AuditInterceptor {
@AroundInvoke
public Object
auditOperation(InvocationContext inv) {
try {
Object result = inv.proceed();
// Add auditing code here
return result;
} catch (Exception ex) {
…
}
}
Persistence API
26
Can be used outside Java EE platform-based containers
also
Evolution into “common” Java persistence API
Support for pluggable third-party persistence providers
Persistence Model
27
Entities are simple Java classes
Concrete java classes
No required interfaces
Usable as “detached” objects in other tiers
No more need for DTOs
EntityManager is used to manage entities
Creates, removes and finds entities
Usable across multiple transactions, spanning multiple
user requests
Extended persistence context
EJB 3.0 Entity - Example
28
Order.java
@Entity
@Table(name="ORDER_TABLE")
public class Order {
@Id
@GeneratedValue
protected long orderId;
@OneToOne
protected Item item;
...
}
Item.java
@Entity
public class Item {
protected long SKU;
@Id
@GeneratedValue
public long getSKU() { return SKU; }
}
Entity Manager
29
Provides entity operations
Methods for lifecycle operations
Persist, remove, merge, flush, refresh, etc.
Convenience query methods (find)
EntityManager is factory for Query objects
Static (named) and dynamic queries, EJB QL and SQL
queries
Manages persistence context
Both transaction-scoped and extended persistence
contexts
Similar in functionality to Hibernate Session, JDO
PersistenceManager, etc.
EJB 3.0 Entity Manager- Example
30
// Creating the entity
public void createNewOrder(Order order){
EntityManager em = getEntityManager();
try{
em.getTransaction().begin();
em.persist(order);
em.getTransaction().commit();
}
finally{ em.close(); } }
// Finding and updating the entity
public void alterOrderQuantity(long orderId, int
newQuantity){
EntityManager em = getEntityManager();
try{
em.getTransaction().begin();
Order order = em.find(Order.class,
orderId);
order.setQuantity(newQuantity);
em.getTransaction().commit();
}finally{ em.close(); } }
31
Named queries are predefined static queries that are precompiled.
They can take parameters, but the query remains the same.
@NamedQuery(
name="MyEntity.getItemsPerProductCategory",
query="SELECT i FROM Item i WHERE i.product.categoryID
LIKE :cID"
)
@Entity
public class MyEntity { ...
}
// Using named queries
public class MyDataFacade ... {
private EntityManager em;
...
public List<Items> getItems(String catID) {
Query query =
em.createNamedQuery("MyEntity.getItemsPerProduct
Category");
query.setParameter("cID",catID);
List<Item> items = query.getResultList();
return items;
}
EJB – Compatibility and
Migration
32
Existing applications continue to work
Provides integration with existing applications and
components
Allows components to be updated or replaced (using
EJB 3.0 APIs) without affecting existing clients
Facilitates EJB 3.0 technology adoption with
incremental migration
Migrating EJB 2.1 to EJB 3.0
33
0
2
4
6
8
10
12
14
16
18
# of Java Files # of XML Files
EJB 2.1
EJB 3.0
No. of files EJB
2.1
EJB
3.0
Java Files 17 7
XML Files 9 2
 Migration of the RosterApp, available as a sample
application in public domain
 No. of files comparison %
41%
22%
Migrating EJB 2.1 to EJB 3.0
34
Lines of Code
in
EJB2.1 EJB3.0 %
Java File 987(17) 716(7) 73%
XML File 792(9) 26(2) 3%
 Migration of the RosterApp, available as a sample
application in public domain
 LOC comparison
0
100
200
300
400
500
600
700
800
900
1000
# of lines (Java) # of lines (XML)
EJB 2.1
EJB 3.0
EJB 3.0 Summary
35
 EJB technology simplified for developers
Fewer classes and interfaces
Injection model for container services and resources
Removal of boilerplate code
Elimination of need for deployment descriptors
Independent Persistence specification
Entities are POJOs enabling detached entities
Improved query capabilities
O/R mapping specification
 EJB 3.0 applications interoperate with existing applications
Resources
• JSR 220: Enterprise JavaBeans™,Version 3.0
EJB 3.0 Simplified API
EJB Core Contracts and Requirements
Java Persistence API
• Enterprise JavaBeans Technology
http://java.sun.com/products/ejb/
• EJB
http://dev2dev.bea.com/ejb/
• The Simplicity of EJB 3.0/
http://java.sys-con.com/read/117755_1.htm
36
Skillwise EJB3.0 training

More Related Content

What's hot

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
 
EJB3 Basics
EJB3 BasicsEJB3 Basics
EJB3 BasicsEmprovise
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJBPeter R. Egli
 
Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006achraf_ing
 
Entity beans in java
Entity beans in javaEntity beans in java
Entity beans in javaAcp Jamod
 
Ejb 2.0
Ejb 2.0Ejb 2.0
Ejb 2.0sukace
 
EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionKelum Senanayake
 
Session 3 Tp3
Session 3 Tp3Session 3 Tp3
Session 3 Tp3phanleson
 
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
 
Java Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 BasicsJava Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 BasicsIMC Institute
 
Enterprise Java Beans( E)
Enterprise  Java  Beans( E)Enterprise  Java  Beans( E)
Enterprise Java Beans( E)vikram singh
 
Types of Dependency Injection in Spring
Types of Dependency Injection in SpringTypes of Dependency Injection in Spring
Types of Dependency Injection in SpringSunil kumar Mohanty
 

What's hot (20)

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 2
EJB 2EJB 2
EJB 2
 
Ejb3 Presentation
Ejb3 PresentationEjb3 Presentation
Ejb3 Presentation
 
EJB3 Basics
EJB3 BasicsEJB3 Basics
EJB3 Basics
 
Java EE EJB Applications
Java EE EJB ApplicationsJava EE EJB Applications
Java EE EJB Applications
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006
 
Entity beans in java
Entity beans in javaEntity beans in java
Entity beans in java
 
Ejb notes
Ejb notesEjb notes
Ejb notes
 
Java bean
Java beanJava bean
Java bean
 
Ejb 2.0
Ejb 2.0Ejb 2.0
Ejb 2.0
 
EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another Introduction
 
enterprise java bean
enterprise java beanenterprise java bean
enterprise java bean
 
Session 3 Tp3
Session 3 Tp3Session 3 Tp3
Session 3 Tp3
 
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
 
Java Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 BasicsJava Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 Basics
 
Enterprise java beans
Enterprise java beansEnterprise java beans
Enterprise java beans
 
EJB 3.0 and J2EE
EJB 3.0 and J2EEEJB 3.0 and J2EE
EJB 3.0 and J2EE
 
Enterprise Java Beans( E)
Enterprise  Java  Beans( E)Enterprise  Java  Beans( E)
Enterprise Java Beans( E)
 
Types of Dependency Injection in Spring
Types of Dependency Injection in SpringTypes of Dependency Injection in Spring
Types of Dependency Injection in Spring
 

Viewers also liked

Skillwise Automated Testing
Skillwise Automated TestingSkillwise Automated Testing
Skillwise Automated TestingSkillwise Group
 
Spring framework part 2
Spring framework  part 2Spring framework  part 2
Spring framework part 2Skillwise Group
 
Skillwise Struts.x
Skillwise Struts.xSkillwise Struts.x
Skillwise Struts.xSkillwise Group
 
Skillwise - Cobol Programming Basics
Skillwise - Cobol Programming BasicsSkillwise - Cobol Programming Basics
Skillwise - Cobol Programming BasicsSkillwise Group
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 

Viewers also liked (7)

Skillwise Automated Testing
Skillwise Automated TestingSkillwise Automated Testing
Skillwise Automated Testing
 
Spring framework part 2
Spring framework  part 2Spring framework  part 2
Spring framework part 2
 
Skillwise Struts.x
Skillwise Struts.xSkillwise Struts.x
Skillwise Struts.x
 
Skilwise Big data
Skilwise Big dataSkilwise Big data
Skilwise Big data
 
Skillwise Profile
Skillwise ProfileSkillwise Profile
Skillwise Profile
 
Skillwise - Cobol Programming Basics
Skillwise - Cobol Programming BasicsSkillwise - Cobol Programming Basics
Skillwise - Cobol Programming Basics
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 

Similar to Skillwise EJB3.0 training

ADVANCED JAVA MODULE I & II.ppt
ADVANCED JAVA MODULE I & II.pptADVANCED JAVA MODULE I & II.ppt
ADVANCED JAVA MODULE I & II.pptrani marri
 
CommercialSystemsBahman.ppt
CommercialSystemsBahman.pptCommercialSystemsBahman.ppt
CommercialSystemsBahman.pptKalsoomTahir2
 
J2 Ee Overview
J2 Ee OverviewJ2 Ee Overview
J2 Ee OverviewAtul Shridhar
 
Aravind vinnakota ejb_architecture
Aravind vinnakota ejb_architectureAravind vinnakota ejb_architecture
Aravind vinnakota ejb_architecturetayab4687
 
Ejb examples
Ejb examplesEjb examples
Ejb examplesvantinhkhuc
 
EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)Montreal JUG
 
Enterprise java beans(ejb)
Enterprise java beans(ejb)Enterprise java beans(ejb)
Enterprise java beans(ejb)vikram singh
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2vikram singh
 
J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical OverviewSvetlin Nakov
 
P20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptxP20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptxDrTCVijayaraghavan
 
Enterprise java beans(ejb)
Enterprise java beans(ejb)Enterprise java beans(ejb)
Enterprise java beans(ejb)vikram singh
 
JBoss AS7 OSDC 2011
JBoss AS7 OSDC 2011JBoss AS7 OSDC 2011
JBoss AS7 OSDC 2011Jason Shepherd
 
Data access
Data accessData access
Data accessJoshua Yoon
 
Javaee6 Overview
Javaee6 OverviewJavaee6 Overview
Javaee6 OverviewCarol McDonald
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2vikram singh
 
Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2vikram singh
 
Spring training
Spring trainingSpring training
Spring trainingTechFerry
 
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 6Antonio Goncalves
 

Similar to Skillwise EJB3.0 training (20)

ADVANCED JAVA MODULE I & II.ppt
ADVANCED JAVA MODULE I & II.pptADVANCED JAVA MODULE I & II.ppt
ADVANCED JAVA MODULE I & II.ppt
 
CommercialSystemsBahman.ppt
CommercialSystemsBahman.pptCommercialSystemsBahman.ppt
CommercialSystemsBahman.ppt
 
J2 Ee Overview
J2 Ee OverviewJ2 Ee Overview
J2 Ee Overview
 
Aravind vinnakota ejb_architecture
Aravind vinnakota ejb_architectureAravind vinnakota ejb_architecture
Aravind vinnakota ejb_architecture
 
Ejb examples
Ejb examplesEjb examples
Ejb examples
 
EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)
 
Enterprise java beans(ejb)
Enterprise java beans(ejb)Enterprise java beans(ejb)
Enterprise java beans(ejb)
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2
 
J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical Overview
 
Ch4 ejb
Ch4 ejbCh4 ejb
Ch4 ejb
 
P20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptxP20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptx
 
Enterprise java beans(ejb)
Enterprise java beans(ejb)Enterprise java beans(ejb)
Enterprise java beans(ejb)
 
JBoss AS7 OSDC 2011
JBoss AS7 OSDC 2011JBoss AS7 OSDC 2011
JBoss AS7 OSDC 2011
 
Data access
Data accessData access
Data access
 
Javaee6 Overview
Javaee6 OverviewJavaee6 Overview
Javaee6 Overview
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2
 
Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2
 
Spring training
Spring trainingSpring training
Spring training
 
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 intro
Ejb introEjb intro
Ejb intro
 

More from Skillwise Group

Skillwise Consulting New updated
Skillwise Consulting New updatedSkillwise Consulting New updated
Skillwise Consulting New updatedSkillwise Group
 
Healthcare profile
Healthcare profileHealthcare profile
Healthcare profileSkillwise Group
 
Manufacturing courses
Manufacturing coursesManufacturing courses
Manufacturing coursesSkillwise Group
 
Retailing & logistics profile
Retailing & logistics profileRetailing & logistics profile
Retailing & logistics profileSkillwise Group
 
Skillwise orientation
Skillwise orientationSkillwise orientation
Skillwise orientationSkillwise Group
 
Overview- Skillwise Consulting
Overview- Skillwise Consulting Overview- Skillwise Consulting
Overview- Skillwise Consulting Skillwise Group
 
Skillwise corporate presentation
Skillwise corporate presentationSkillwise corporate presentation
Skillwise corporate presentationSkillwise Group
 
Skillwise Softskill Training Workshop
Skillwise Softskill Training WorkshopSkillwise Softskill Training Workshop
Skillwise Softskill Training WorkshopSkillwise Group
 
Skillwise Insurance profile
Skillwise Insurance profileSkillwise Insurance profile
Skillwise Insurance profileSkillwise Group
 
Skillwise Train and Hire Services
Skillwise Train and Hire ServicesSkillwise Train and Hire Services
Skillwise Train and Hire ServicesSkillwise Group
 
Skillwise Digital Technology
Skillwise Digital Technology Skillwise Digital Technology
Skillwise Digital Technology Skillwise Group
 
Skillwise Boot Camp Training
Skillwise Boot Camp TrainingSkillwise Boot Camp Training
Skillwise Boot Camp TrainingSkillwise Group
 
Skillwise Academy Profile
Skillwise Academy ProfileSkillwise Academy Profile
Skillwise Academy ProfileSkillwise Group
 
Skillwise Overview
Skillwise OverviewSkillwise Overview
Skillwise OverviewSkillwise Group
 
Skillwise - Business writing
Skillwise - Business writing Skillwise - Business writing
Skillwise - Business writing Skillwise Group
 
Skillwise cics part 1
Skillwise cics part 1Skillwise cics part 1
Skillwise cics part 1Skillwise Group
 
Skillwise Elementary Java Programming
Skillwise Elementary Java ProgrammingSkillwise Elementary Java Programming
Skillwise Elementary Java ProgrammingSkillwise Group
 

More from Skillwise Group (20)

Skillwise Consulting New updated
Skillwise Consulting New updatedSkillwise Consulting New updated
Skillwise Consulting New updated
 
Email Etiquette
Email Etiquette Email Etiquette
Email Etiquette
 
Healthcare profile
Healthcare profileHealthcare profile
Healthcare profile
 
Manufacturing courses
Manufacturing coursesManufacturing courses
Manufacturing courses
 
Retailing & logistics profile
Retailing & logistics profileRetailing & logistics profile
Retailing & logistics profile
 
Skillwise orientation
Skillwise orientationSkillwise orientation
Skillwise orientation
 
Overview- Skillwise Consulting
Overview- Skillwise Consulting Overview- Skillwise Consulting
Overview- Skillwise Consulting
 
Skillwise corporate presentation
Skillwise corporate presentationSkillwise corporate presentation
Skillwise corporate presentation
 
Skillwise Softskill Training Workshop
Skillwise Softskill Training WorkshopSkillwise Softskill Training Workshop
Skillwise Softskill Training Workshop
 
Skillwise Insurance profile
Skillwise Insurance profileSkillwise Insurance profile
Skillwise Insurance profile
 
Skillwise Train and Hire Services
Skillwise Train and Hire ServicesSkillwise Train and Hire Services
Skillwise Train and Hire Services
 
Skillwise Digital Technology
Skillwise Digital Technology Skillwise Digital Technology
Skillwise Digital Technology
 
Skillwise Boot Camp Training
Skillwise Boot Camp TrainingSkillwise Boot Camp Training
Skillwise Boot Camp Training
 
Skillwise Academy Profile
Skillwise Academy ProfileSkillwise Academy Profile
Skillwise Academy Profile
 
Skillwise Overview
Skillwise OverviewSkillwise Overview
Skillwise Overview
 
Skillwise - Business writing
Skillwise - Business writing Skillwise - Business writing
Skillwise - Business writing
 
Imc.ppt
Imc.pptImc.ppt
Imc.ppt
 
Skillwise cics part 1
Skillwise cics part 1Skillwise cics part 1
Skillwise cics part 1
 
Skillwise AML
Skillwise AMLSkillwise AML
Skillwise AML
 
Skillwise Elementary Java Programming
Skillwise Elementary Java ProgrammingSkillwise Elementary Java Programming
Skillwise Elementary Java Programming
 

Recently uploaded

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Skillwise EJB3.0 training

  • 2. Goal Learn how EJB 3.0 technology simplifies Java EE application development
  • 3. Content Overview and Background EJB 3.0 - What’s New ? EJB 3.0 API EJB 3.0 Persistence Compatibility and Migration Summary Resources Agenda
  • 4. What is EJB? A server side component architecture for the development and deployment of distributed, enterprise applications in Java. Typically contain the business logic of an enterprise application EJB applications are scalable, transactional, multi-user and secure. EJB components are managed by the EJB container that is part of a Java EE server
  • 6. Advantages of EJB Write Once, Deploy Anywhere Frees the application developer from having to deal with the system level aspects of an application. Behavior can be configured at deployment without modifying the source code Rapid and simplified development of distributed, transactional, secure and portable Java EE applications
  • 7. Types of EJBs Session Bean Stateful Session Bean Stateless Session Bean Entity Bean • Based on persistence types, Bean managed Container managed Message Driven Bean
  • 8. An EJB 2.1 Example 8 // Bean class public class HelloBean implements SessionBean { private SessionContext sessionContext; public void ejbCreate() { } public void ejbRemove() { } public void ejbActivate() { } public void ejbPassivate() { } public void setSessionContext(SessionContext sessionContext) { this.sessionContext = sessionContext; } public String sayHello() { return "Hello World!!!!!"; } } // Home Interface public interface HelloHome extends EJBHome { public Hello create() throws RemoteException, CreateException; } // Remote Interface public interface Hello extends EJBObject { public String sayHello() throws RemoteException; }
  • 9. An EJB 2.1 Example (Contd.) 9 // Entry in ejb-jar.xml (deployment descriptor) <session> <ejb-name>Hello</ejb-name> <home>com.jlive.demo.hello.HelloHome</home> <remote>com.jlive.demo.hello.Hello</remote> <ejb-class>com.jlive.demo.hello.HelloBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Bean</transaction-type> </session> //Client code public class HelloClient { public static void main(String [] args) throws Exception { Context jndiContext = new InitialContext(); Object ref = jndiContext.lookup("Hello"); HelloHome helloHome = (HelloHome) PortableRemoteObject.narrow(ref, HelloHome.class); Hello hello = helloHome.create(); System.out.println(hello.sayHello()); } }
  • 10. What was wrong with EJB 2.1? EJB 2.1 technology Very powerful, but complex to use Too many classes, interfaces Java Naming and Directory Interface™(JNDI) API lookups javax.ejb interfaces Awkward programming model Deployment descriptors Entity bean anti-patterns Difficult to test entities outside the container
  • 11. EJB 3.0 - What’s New ? Simplification of the EJB APIs Utilizes advantages of Java metadata annotations More work is done by container, less by developer Dependency injection New Persistence API Specification
  • 12. EJB 3.0 Bean Simplification Elimination of EJB component interfaces Business interfaces are plain Java interfaces Elimination of Home interfaces Only need business interface, not home Elimination of requirements for javax.ejb.EnterpriseBean interfaces Annotations for (optional) callbacks Elimination of need for use of JNDI API Use dependency injection, simple lookup method
  • 13. Example – EJB 3.0 13 // Bean class @Stateless public class NewHelloBean implements NewHello{ public String sayHello() { return "Hello New World!!!!!"; } } // Business Interface @Remote public interface NewHello { public String sayHello(); } // Client code public class NewHelloClient { public static void main(String [] args) throws Exception { Context jndiContext = new InitialContext(); Object ref = jndiContext.lookup("NewHello"); NewHello hello = (NewHello)ref; System.out.println(hello.sayHello()); } }
  • 14. MDB in EJB 3.0 14 @MessageDriven(activateConfig = { @ActivationConfigProperty(propertyName="destinationTy pe", propertyValue="javax.jms.Queue"), @ActivationConfigProperty(propertyName="destination", propertyValue="queue/mdb") }) public class CalculatorBean implements MessageListener { public void onMessage (Message msg) { try { TextMessage tmsg = (TextMessage) msg; } catch (Exception e) { e.printStackTrace (); } } // ... ... } Message driven beans are components designed to handle message based requests The MDB must implement the Message Listener interface. The on Message method is invoked when a message is received by the container
  • 15. Resource Injection Resource injection is an inversion of dependency Resources can be injected on bean creation References of DataSources, UserTransaction, Environment entries, EntityManager, Other EJB beans Annotations @EJB @Resource Injection can be specified using deployment descriptor
  • 16. Resource Injection – EJB 3.0 16 @Resource(name=”myDB”, type=javax.sql.DataSource) @Stateful public class ShoppingCartBean implements ShoppingCart { @Resource SessionContext ctx; public Collection startToShop (String productName) { ... DataSource productDB = (DataSource)ctx.lookup(“myDB”); Connection conn = myDB.getConnection(); ... } ... }
  • 17. Simplified Client View 17 Clients can easily lookup enterprise beans using the @EJB annotation Access can be Remote/Local. Remoteness is hidden // EJB 2.1 Client view of the ShoppingCart bean ... Context initialContext = new InitialContext(); ShoppingCartHome myCartHome = (ShoppingCartHome) initialContext.lookup(“java:comp/env/ejb/cart”); ShoppingCart myCart= myCartHome.create(); //Use the bean Collection widgets = myCart.startToShop(“widgets”) ... // catch javax.ejb.CreateException/javax.ejb.EJBException
  • 18. • // EJB 3.0 client view • @EJB ShoppingCart myCart; • ... • Collection widgets = myCart.startToShop(“widgets”); • ...
  • 19. EJB 3.0 Transactions 19 CMT by default, BMT by annotation Specified at class level or method level Default is CMT + REQUIRED
  • 20. • // Uses container-managed transaction, REQUIRED attribute • @Stateless public PayrollBean implements Payroll { • @TransactionAttribute(MANDATORY) • public void setBenefitsDeduction(int empId, double deduction) {...} • public double getBenefitsDeduction(int empId) {...} • public double getSalary(int empid) {...} • @TransactionAttribute(REQUIRES_NEW) • public void setSalary(int empId, double salary) {...} • }
  • 21. EJB 3.0 Security 21 Security configuration preferred at deployment Annotations - @Unchecked, @RolesAllowed Default is unchecked // Security view @Stateless public PayrollBean implements Payroll { public void setBenefitsDeduction(int empId, double deduction) {...} public double getBenefitsDeduction(int empId) {...} public double getSalary(int empid) {...} // salary setting is intended to be more restricted @RolesAllowed(“HR_PayrollAdministrator”) public void setSalary(int empId, double salary) {...} }
  • 22. EJB 3.0 Callback - Event Notification 22 Container calls bean upon lifecycle events @PostConstruct, @PreDestroy, @PrePassivate, @PostActivate,… Bean specifies events it needs to know about Callback methods can be specified on lifecycle listener
  • 23. 23
  • 24. EJB 3.0 Interceptors Interception of invocations of business methods and/or message listener methods Invocation model: “around” methods Wrapped around business method invocations Interceptor has control over invocation of “next method” Can manipulate arguments and results Context data can be carried across invocation chain Execute in specified order Can use deployment descriptor to override order or add interceptors Annotations  @Interceptors, @AroundInvoke
  • 25. EJB 3.0 Interceptors - Example 25 @Interceptors({ com.demo.AuditInterceptor.class, com.demo.LoggerInterceptor.class }) @Stateless public class AccountManagementBean implements AccountManagement { public void createAccount(int accountId, Details details) {...} public void deleteAccount(int accountId) {...} } public class AuditInterceptor { @AroundInvoke public Object auditOperation(InvocationContext inv) { try { Object result = inv.proceed(); // Add auditing code here return result; } catch (Exception ex) { … } }
  • 26. Persistence API 26 Can be used outside Java EE platform-based containers also Evolution into “common” Java persistence API Support for pluggable third-party persistence providers
  • 27. Persistence Model 27 Entities are simple Java classes Concrete java classes No required interfaces Usable as “detached” objects in other tiers No more need for DTOs EntityManager is used to manage entities Creates, removes and finds entities Usable across multiple transactions, spanning multiple user requests Extended persistence context
  • 28. EJB 3.0 Entity - Example 28 Order.java @Entity @Table(name="ORDER_TABLE") public class Order { @Id @GeneratedValue protected long orderId; @OneToOne protected Item item; ... } Item.java @Entity public class Item { protected long SKU; @Id @GeneratedValue public long getSKU() { return SKU; } }
  • 29. Entity Manager 29 Provides entity operations Methods for lifecycle operations Persist, remove, merge, flush, refresh, etc. Convenience query methods (find) EntityManager is factory for Query objects Static (named) and dynamic queries, EJB QL and SQL queries Manages persistence context Both transaction-scoped and extended persistence contexts Similar in functionality to Hibernate Session, JDO PersistenceManager, etc.
  • 30. EJB 3.0 Entity Manager- Example 30 // Creating the entity public void createNewOrder(Order order){ EntityManager em = getEntityManager(); try{ em.getTransaction().begin(); em.persist(order); em.getTransaction().commit(); } finally{ em.close(); } } // Finding and updating the entity public void alterOrderQuantity(long orderId, int newQuantity){ EntityManager em = getEntityManager(); try{ em.getTransaction().begin(); Order order = em.find(Order.class, orderId); order.setQuantity(newQuantity); em.getTransaction().commit(); }finally{ em.close(); } }
  • 31. 31 Named queries are predefined static queries that are precompiled. They can take parameters, but the query remains the same. @NamedQuery( name="MyEntity.getItemsPerProductCategory", query="SELECT i FROM Item i WHERE i.product.categoryID LIKE :cID" ) @Entity public class MyEntity { ... } // Using named queries public class MyDataFacade ... { private EntityManager em; ... public List<Items> getItems(String catID) { Query query = em.createNamedQuery("MyEntity.getItemsPerProduct Category"); query.setParameter("cID",catID); List<Item> items = query.getResultList(); return items; }
  • 32. EJB – Compatibility and Migration 32 Existing applications continue to work Provides integration with existing applications and components Allows components to be updated or replaced (using EJB 3.0 APIs) without affecting existing clients Facilitates EJB 3.0 technology adoption with incremental migration
  • 33. Migrating EJB 2.1 to EJB 3.0 33 0 2 4 6 8 10 12 14 16 18 # of Java Files # of XML Files EJB 2.1 EJB 3.0 No. of files EJB 2.1 EJB 3.0 Java Files 17 7 XML Files 9 2  Migration of the RosterApp, available as a sample application in public domain  No. of files comparison % 41% 22%
  • 34. Migrating EJB 2.1 to EJB 3.0 34 Lines of Code in EJB2.1 EJB3.0 % Java File 987(17) 716(7) 73% XML File 792(9) 26(2) 3%  Migration of the RosterApp, available as a sample application in public domain  LOC comparison 0 100 200 300 400 500 600 700 800 900 1000 # of lines (Java) # of lines (XML) EJB 2.1 EJB 3.0
  • 35. EJB 3.0 Summary 35  EJB technology simplified for developers Fewer classes and interfaces Injection model for container services and resources Removal of boilerplate code Elimination of need for deployment descriptors Independent Persistence specification Entities are POJOs enabling detached entities Improved query capabilities O/R mapping specification  EJB 3.0 applications interoperate with existing applications
  • 36. Resources • JSR 220: Enterprise JavaBeans™,Version 3.0 EJB 3.0 Simplified API EJB Core Contracts and Requirements Java Persistence API • Enterprise JavaBeans Technology http://java.sun.com/products/ejb/ • EJB http://dev2dev.bea.com/ejb/ • The Simplicity of EJB 3.0/ http://java.sys-con.com/read/117755_1.htm 36