Structure of Enterprise Java Beans - PowerPoint PPT Presentation

About This Presentation
Title:

Structure of Enterprise Java Beans

Description:

Structure of Enterprise Java Beans Introduction Main goal of Enterprise Java Bean (EJB) architecture is to free the application developer from having to deal with the ... – PowerPoint PPT presentation

Number of Views:99
Avg rating:3.0/5.0
Slides: 13
Provided by: Kuma85
Category:

less

Transcript and Presenter's Notes

Title: Structure of Enterprise Java Beans


1
Structure of Enterprise Java Beans
2
Introduction
  • Main goal of Enterprise Java Bean (EJB)
    architecture is to free the application developer
    from having to deal with the system level aspects
    of an application. This allows the bean developer
    to focus solely on the logic of the application.

3
Parts of EJB
  • EJB class that implements the business methods
    and life cycle methods uses other helper classes
    and libraries to implement.
  • Client-view API consists of EJB home interface
    and remote interface.
  • Home interface controls life cycle create,
    remove, find methods
  • Remote interface to invoke the EJB object methods

4
Parts of EJB (contd.)
  • Deployment Descriptor XML document for bean
    assembler and deployer
  • A declaration about EJB environment needed for
    customizing the bean to the operating
    environment.
  • Container Runtime services include transactions,
    security,distribution,load balancing,
    multithreading, persistence, failure recovery,
    resource pooling, state amnagement, clustering..

5
Naming Convention
  • EJB class is a descriptive name of the business
    entity or process with the word Bean appended.
    Ex AccountBean
  • Home interface is same as business entity name
    with the word Home appended. Ex AccountHome
  • Remote interface is just the name of the entity.
    Ex Account
  • The name of the entire EJB (reference in
    deployment descriptor) is same as the enity name
    with EJB appended. Ex AccountEJB

6
Enterprise Bean Parts
ltltHome Interfacegtgt AccountHome
ltltRemote Interfacegtgt Account
create() find() remove()
debit() credit() getBalance()
ltltEnterrpise Bean classgt AccountBean
Deployment Descriptor
name AccountEJB class AccountBean home
AccountHome remote Account type
Entity transaction required ..
ejbCreate() ejbFind() ejbRemove() debit() credit()
getBalance()
7
AccountHome Interface
import java.rmi.RemoteException import
javax.ejb.CreateException import
javax.ejb.FinderException import
java.util.Collection public interface
AccountHome extends javax.ejb.EJBHome //create
methods Account create (String lastName, String
firstName) throws RemoteException,
CreateException,
BadNameException Account create (String
lastName) throws RemoteException,
CreateException // find methods Account
findByPrimaryKey (AccountKey primaryKey) throws
RemoteException,

FinderException Collection findInActive(Date
sinceWhen) throws RemoteException,
FinderException, BadDateException
8
EJBHome Interface
import java.rmi.RemoteException public
interface EJBHome extends java.rmi.Remote void
remove(Handle handle) throws RemoteException,
RemoveException void remove(Object primaryKey)
throws RemoteException, RemoveException
EJBMetaData getEJBMetaData( ) throws
RemoteException HomeHandle getHomeHandle()
throws RemoteException
9
Account Interface
import java.rmi.RemoteException public
interface Account extends javax.ejb.EJBObject
BigDecimal getBalance() throws
RemoteException void credit(BiGDecimal amount)
throws RemoteException Void debit(BigDecimal
amount) throws RemoteException,
InSufficientFundsException
10
EJBObject Interface
import java.rmi.RemoteException public
interface EJBObject extends java.rmi.Remote
public EJBHome getEJBHome() throws
RemoteException public Object getPrimaryKey()
throws RemoteException public void remove()
throws RemoteException, RemoveException Public
Handle getHandle() throws RemoteException Boolean
isIdentical (EJBObject obj2) throws
RemoteException
11
AccountBean class
public class AccountBean implements
javax.ejb.EntityBean // life cycle methods from
home interface public AccountKey ejbCreate
(String latName, String firstName) throws
public AccountKey ejbCreate(String lastName)
throws public AccountKey ejbFindByPrimaryKey(
AccountKey primarykey) Public Collection
ejbFindInactive( Data sinecWhen).. //
business methods from remote interface public
BigDecimal getBalance() . public void
credit(BigDecimal amt) Public void
debit(BigDecimal amt) throws InsufficientFundExcep
tion . // container callbacks from EntityBean
container public ejbRemove( ) throws
RemoveException public void
setEntityContext(EntityContext ec) public
unsetEntityContext(EntityContext ec) public
void ejbActivate() public void ejbLoad()
. public void ejbStore() .
12
Deployment Descriptor
ltentity-beangt ltejb-namegtAccountEJBlt/ejb-name
gt lthomegtcom.wombat.AccopuntHomelt/homegt
ltremotegtcom.wombat.Accountlt/remotegt
ltejb-classgtcom.wombat.AccountBeanlt/ejb-classgt
ltpersistence-typegtBeanlt\persistence-typegt
ltprimary-key-classgtcom.wombat.AccountKeylt/primary-
kay-classgt lt/entity-beangt ltcontainer-transactio
ngt ltmethodgt ltejb-namegtAcoountEJBlt/ejb-n
amegt ltmethod-namegtlt/method-namegt
lt/methodgt lttrans-attributegtrequiredlt/trans-att
ributegt lt/container-transactiongt
Write a Comment
User Comments (0)
About PowerShow.com