introduction to enterprise javabeans topics in systems architecture barry herbold...
TRANSCRIPT
Introduction to Introduction to Enterprise JavaBeansEnterprise JavaBeans
Topics In Systems Architecture Barry Herbold
EJB OverviewEJB Overview• Server side softwareServer side software
• What is EJBWhat is EJB
• EJB Application ServersEJB Application Servers
• Types of Enterprise JavaBeansTypes of Enterprise JavaBeans
• How to build an enterprise beanHow to build an enterprise bean
• A simple client interaction scenarioA simple client interaction scenario
Server-side Software Server-side Software ExamplesExamples
• Retail chain stores - Retail chain stores - Each store sends Each store sends inventory and shopping information to servers at retail inventory and shopping information to servers at retail headquarters.headquarters.
• Banks - Banks - ATM machines connect to a central server.ATM machines connect to a central server.
• Web sites -Web sites - Thousands of users connect to web Thousands of users connect to web servers that connect to a central server for data and servers that connect to a central server for data and business logic.business logic.
Enterprise JavaBeansEnterprise JavaBeans
• EJB is a specification that defines how EJB is a specification that defines how server-side components are written and server-side components are written and how application servers manage them.how application servers manage them.
• These deployable components are called These deployable components are called enterprise beans.enterprise beans.
• The enterprise beans are deployed into a The enterprise beans are deployed into a container that provides run time services.container that provides run time services.
EJB Architecture RolesEJB Architecture Roles
Bean Provider ApplicationAssembler
Deployer System Administrator
Container/Server Provider
Construct Enterprise Beans
Build Application Deploy System
Supply
EJB Conta
iner/Serv
er
EJB Container / Application EJB Container / Application Server Server
EJB Server
Enterprise Bean 1
Enterprise Bean 2
Enterprise Bean 3
EJB Container 1 EJB Container 2
Client Code:applets, servlets,
applications
Server and Container ServicesServer and Container Services
• Remote accessRemote access
• Support for multiple Support for multiple clientsclients
• Resource managementResource management
• Component lifecycleComponent lifecycle
• Persistence of objectsPersistence of objects
• Location transparencyLocation transparency
• Security - authentication Security - authentication and authorization and authorization
• Transaction Transaction managementmanagement
EJB Container/Server EJB Container/Server ProvidersProviders
BEA Systems, Inc.BEA Systems, Inc.
OracleOracle
Borland / InpriseBorland / Inprise
IBMIBM
SybaseSybase
Bluestone SoftwareBluestone Software
Enterprise BeansEnterprise Beans
Session BeansSession Beans
• Model business Model business processesprocesses
• Usually exists for Usually exists for duration of a single duration of a single client server sessionclient server session
• Examples: price Examples: price quoting, credit card quoting, credit card validationvalidation
Entity BeansEntity Beans
• Model business dataModel business data
• Data resides in Data resides in underlying storage underlying storage such as a databasesuch as a database
• Examples: employees, Examples: employees, customers, bank customers, bank accountsaccounts
Session BeansSession Beans
Stateless Session Stateless Session BeansBeans
• Do not retain changes in Do not retain changes in state.state.
• Do not maintain identity Do not maintain identity of client across method of client across method calls.calls.
• I.e. a credit card I.e. a credit card verification bean.verification bean.
Stateful Session Stateful Session BeansBeans
• Maintain client identity Maintain client identity across method calls.across method calls.
• Retain state changes on Retain state changes on behalf of the client.behalf of the client.
• I.e. a shopping cart I.e. a shopping cart bean.bean.
Entity BeansEntity Beans
Bean-managed entity Bean-managed entity beansbeans
• Component developer Component developer must write code to load, must write code to load, store and retrieve the store and retrieve the entity bean.entity bean.
Container-managed entity Container-managed entity beansbeans
• The container is responsible for The container is responsible for all access to the underlying all access to the underlying storage.storage.
• Component writer simply Component writer simply describes the fields that describes the fields that should be persisted.should be persisted.
Building A BeanBuilding A Bean
Bean provider must provide the Bean provider must provide the following:following:
• Enterprise bean class filesEnterprise bean class files
• A remote interface A remote interface
• A home interfaceA home interface
• Deployment descriptorsDeployment descriptors
• Properties file - optionalProperties file - optional
The Remote Interface and the EJB The Remote Interface and the EJB ObjectObject
EJB Container/Server
Enterprise BeanEJB Object
Remote Interface
Client Code
1. Call a method
2. Delegate clientrequest to bean
3. Method returns
4. Route return valueback to the client
public interface javax.ejb.EJBObject extends java.rmi.remote
{
...
}
The Home Interface and The Home Interface and ObjectObject
EJB Container/Server
EJB Object
Client Code
Enterprise Beans
Home Object(Object Factory)
HomeInterface
1. Request an EJB objectreference
2. Create EJB object
3. Return EJB object reference
public interface javax.ejb.EJBHome extends java.rmi.remote
{
...
}
Typical Interaction Typical Interaction ScenarioScenario
Client Code
EJB Container/Server
EJB Object Enterprise Beans
Home Object(Object Factory)
Naming Service
JNDI
1. RetrieveHome Objectreference
2.ReturnHome ObjectReference
3. Request a new EJB object
4. Create EJB object
5. Return EJB object reference
6. Invoke BusinessMethod 7. Delegate Request
to bean
8. Return result10. Return resultto client
SummarySummary•The Enterprise JavaBeans specification defines a standard architecture for implementing the business logic of multi-tier applications as reusable components.
•EJB servers are designed to provide run time and middleware services for containers and the components they contain.
• EJB containers are designed to handle details of component life cycle, transactions, and security management. They achieve this by intercepting method calls between the client and the components. This mechanism simplifies development of both components and client side software.
•Component developers are freed from writing to complex and proprietary middleware APIs.
•The Enterprise JavaBeans specification is based on the Java programming language, so enterprise beans take full advantage of the write once, run anywhere Java philosophy.
ReferencesReferences
• Designing Enterprise Applications with the Java 2 Platform, Designing Enterprise Applications with the Java 2 Platform, Enterprise Edition. EJB web site. Sun Microsystems, Inc. 2000. Enterprise Edition. EJB web site. Sun Microsystems, Inc. 2000.
• Enterprise JavaBeans web site. http://java.sun.com/products/ejbEnterprise JavaBeans web site. http://java.sun.com/products/ejb
• Matena, Vlada., Harper, Mark. Enterprise JavaBeans Matena, Vlada., Harper, Mark. Enterprise JavaBeans Specification, v1.1. EJB web site. Sun Microsystems, Inc. 1999. Specification, v1.1. EJB web site. Sun Microsystems, Inc. 1999.
• Roman, Ed. Roman, Ed. Mastering Enterprise JavaBeans and the Java 2 Mastering Enterprise JavaBeans and the Java 2 Platform Enterprise EditionPlatform Enterprise Edition. John Wiley and Sons Inc. 1999. . John Wiley and Sons Inc. 1999.
• Thomas, Anne. Enterprise JavaBeans Technology Server Thomas, Anne. Enterprise JavaBeans Technology Server Component Model for the Java Platform. EJB web site. Patricia Component Model for the Java Platform. EJB web site. Patricia Seybold Group. 1998. Seybold Group. 1998.