Beruflich Dokumente
Kultur Dokumente
Ruslana Svidzinska
CSE690
What is EJB?
Server Components
WORA
Component Portability
EJB technology takes the WORA
concept to a new level.
EJB completely portable across any
vendors EJB compliant application
server. The EJB environment
automatically maps the component
to the underlying vendor-specific
infrastructure services.
Overview of EJB
Technology
EJB Component Model
Enterprise JavaBeans component model
logically extends the JavaBeans component
model to support server component.
Server components are reusable,
prepackaged pieces of application
functionality that are designed to run in an
application server.
EJB can be assembled and customized at
deployment time using tools provided by
Simplifying Development.
The EJB architecture provides an
integrated application framework.
An EJB server automatically
manages a number of tricky
middleware services on behalf of
the application components.
EJB component-builders can
concentrate on writing business
logic rather than complex
middleware
Simplifying Development
(contd)
RESULT:
Application get developed more quickly
Code is of better quality.
Enterprise JavaBeans
Architecture
The EJB architecture specifies the
responsibilities and interactions among
EJB entities
EJBServers
EJBContainers
EnterpriseBeans
EJBClients
Enterprise
Bean
Enterprise
Bean
EJB Container
Clients
EJB Server
EJB Server
Provides
Provides aaRuntime
RuntimeEnvironment
Environment
EJB Server
EJB Container
Provides
Provides aaRun-time
Run-time Environment
Environment
for
for an
an Enterprise
EnterpriseBean
Bean
EJB Container
EJB Server
Enterprise JavaBeans
Enterprise
Bean
Enterprise
Bean
EJB Container
EJB Server
EJB Clients
Enterprise
Bean
EJB Container
Clients
EJB Server
Understanding EJB
Components
JavaBeans vs Enterprise
JavaBeans
EJB Vendors
Have to do all the WORK
Web Server
EJB Application
Server
Enterprise
Middleware
CICS Programs
EJB Container
Browser
Credit Card
Servlet
Shopping
Cart
Databases
Inventory
Application
EJB Server
SAP Modules
Generated at Development
Generated at Deployment
EJBHome
Class
Written by Developer
EJBObject
Class
EJBHome
Interface
Deployment
Descriptor
EJB Server
Manifest
May be generated by
tools that come with an
EJB server
Also manages EJB:
querying (Entity Bean)
deleting (Entity Bean)
EJBHome
Class
EJB Server
Interface
javax.ejb.EJBHome
create()
EJBHome
Class
Clients
EJB Server
EJBHome Class
instantiates
the Bean Class
When the create() method
is called in the EJBHome
Class, it is responsible for
instantiating the Bean
class.
EJB Container
EJBHome
Class
Clients
EJB Server
EJB
Class
EJB Container
EJBObject
Class
Interface
javax.ejb.EJBObject
public interface javax.ejb.EJBObject extends java.rmi.Remote
{
EJBHome getEJBHome() throws RemoteException;
Handle
getHandle() throws RemoteException;
Object
getPrimaryKey() throws RemoteException;
boolean isIdentical(EJBObject obj) throws RemoteException;
void
remove() throws RemoteException, RemoveException;
}
Sample EJBObject
Interface
public interface Customer extends EJBObject
{
public abstract String getId() throws RemoteException;
public abstract String getName() throws RemoteException;
public abstract void setName(String val) throws RemoteException;
public abstract boolean getNameNull() throws RemoteException;
public abstract boolean getIdNull() throws RemoteException;
public abstract Enumeration getAccounts() throws RemoteException;
public abstract void addToAccounts(Account relInst) throws RemoteException;
public abstract void removeFromAccounts(Account relInst)
throws RemoteException;
}
EJBHome
Class
Clients
Clientnowhasreference
totheEJBObjectClass.
NOTAREFERENCE
TOTHEBEAN
ITSELF!!!!
EJBHome
Class
EJB Server
EJB
Class
EJB Container
EJBHome
Class
EJBHome
Class
Clients
EJB Server
EJB
Class
EJB Class
Deployment Descriptor
javax.ejb.deployment.ControlDescriptor
javax.ejb.deployment.DeploymentDescriptor
javax.ejb.deployment.EntityDescriptor
javax.ejb.deployment.SessionDescriptor
EJB Container
Deployment
Descriptor
EJB Server
Sample Contents of a
Deployment Descriptor
PS(TicketDemo,Concert,deployment_descriptor)
Entity{
VersionNumber
{
1.0
}
BeanHomeName
{
ConcertHome
}
ControlDescriptor
{
IsolationLevel
{
TRANSACTION_READ_COMMITTED
}
Method Level
Security Attribute
Method Level
Transaction Attribute
Method
{
int getId() throws java.rmi.RemoteException
}
RunAsMode
{
SYSTEM_IDENTITY
}
TransactionAttribute
{
TX_SUPPORTS
}
Enterprise JavaBean
Packaging
Name: bank/AccountDeployment.ser
Enterprise-Bean: True
Manifest
EJB Server
Written by Developer
Generated at Development
Generated at Deployment
EJBHome
Class
EJB Container
EJB Class
EJBObject
Class
EJBHome
Interface
EJBObject
Interface
Deployment
Descriptor
EJB Server
Manifest
Enterprise Beans:
Session Beans & Entity Beans
Session Beans vs. Entity Beans
Bean-Managed Persistence
Container-Managed Persistence
EJB Transaction Attributes
Short-lived
Transient
Can be any Java class
May be transactional
Business Logic Beans
Entity Beans
Long-lived
Persistent
Can be a class that maps
to persistent data
(e.g., database)
Always transactional
Beans which represent
data
Session Beans
Represents Process
Entity Bean
Represents Data
fooKey = fooBean.getPrimaryKey();
fooBean = fooHome.findByPrimaryKey(fooKey);
customerBean = customerHome.create(Jane",
Rodgers");
BeanHome.findSomething() is equivalent to an
SQL SELECT
Creates a bean instance that represents queried data
from a database
Can also return an enumeration to represent multiple
rows of data
There will typically be many find Something() methods:
customerBean =
customerHome.findByName(firstName, lastName);
customerBeans = customerHome.findByZip(94023);
customerBean = customerHome.findByName(Jane,
Rodgers);
customerBean.remove();
customerBean = customerHome.findByName(Jane,
Rodgers);
customerBean.setEmailAddress(jane.rodgers@yahoo.com);
EJB Persistence
Provides Entity Beans the ability to
store and retrieve their state
Can be implemented by a bean
Can be implemented by a
container
Container Managed Persistence
Container Managed
Persistence
TX_NOT_SUPPORTED
TX_SUPPORTS
TX_BEAN_MANAGED
TX_REQUIRES_NEW
TX_REQUIRED
TX_MANDATORY