JaiswalTraining

Get the online training



Corejava Servlet Jsp  Php  Hibernate  Ajax Web Service   Ejb2.1 Ejb3.0 Struts Struts2  JPA Spring Ibatis   JSF    JSF2.0  CoreJavaDesignPattern    Jquery  Flex J2EE-Design-Patterns  Jboss7  Maven  Contact Me                                                                                                                                                                        
            IGNOU SMU PTU Project                                           Training                                                                                                                              
              

Contact Us  0091- 9210721663         jaiswaltraining@gmail.com




Corejava
Servlet
Jsp
Php
Hibernate
Ajax
Web Service
Ejb2.1
Ejb3.0
Struts  
Struts2
JPA
Spring
Ibatis
JSF
JSF2.0
CoreJavaDesignPattern
Jquery
Flex
J2EE-Design-Patterns
Jboss7
Maven








EJB 3 Goals

• Simplify developers life
• EJB now resembles Plain Java Object (POJO)
• Use metadata annotations
• XML descriptors are no longer necessary
• Default
• Unnecessary artifacts are optional
• Simplify client view using dependency injection
• Standardize persistence API for Java platform
• Based on success of leading ORM solutions
• Including Oracle TopLink, Hibernate

The EJB 3 provide an alternative to the CMP Entity
  • Beans to access the database.
  • Unlike the previous ones, they are synchronized with the
  • database only when decided by the program.





Simplify EJB Development

• POJO  (Plain Old Java Object) Class
• EJB Class will be a plain java class
• POJI (Plain Old Java interface)
• Regular business interface
• EJB interface does not have to implement EJBObject
• No need of home interface
• Annotations for type of EJB and interface



EJB 2.1  Session Bean Class

public class CartEJB implements SessionBean
{
protected Collection items = new ArrayList();
public void add(String item)
{
items.add(item);
}
public CollectiongetItems()
{
return items;
}
public voidcompleteOrder(){ .. }
public void ejbCreate(){}
public voidejbActivate(){}
public voidejbPassivate(){}
public void ejbRemove(){}
public voidsetSessionContext(SessionContext context){}
}

EJB 2 Deployment Descriptor
<session>
<display-name>Shopping Cart</display-name>
<ejb-name>MyCart</ejb-name>
<home>CartHome</home>
<remote>Cart</remote>
<ejb-class>CartEJB</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>




EJB 3 : Simplifying with annotations
  • @Stateless
  • @Stateful
  • @MessageDriven
  • @Entity


Same Example: EJB 3
@Stateful
public class CartBean implements Cart {
private ArrayList items;
public void add(String item) {
items.add(item);
}
public CollectiongetItems() {
return items;
}
@Remove
public void completeOrder()
{
}
}


Same Example: EJB 3
@Remote
public interface Cart {
public void addItem(String item);
public void completeOrder();
public CollectiongetItems();
}

EJB 3 Simplifications

• Eliminated requirement for Home Interface
• Not needed for session beans
• Business interface is a POJI
• Bean can implement it
• Bean can have more than one business interface
• Can support remote access
• EJB(Local)Object removed from client view
• RemoteExceptionsare removed  from programmer and client view
• Eliminated requirement for unnecessary callbackmethods
• Removed requirement to implement javax.ejb.SessionBean



EJB3 in Jboss

EJB3 in Weblogic

EJB3 in Websphere

EJB3 in  Glassfish