Enterprise JavaBeans Overview - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

Enterprise JavaBeans Overview

Description:

simple query) or Stateful (more typical for shopping cart) Exists for life of Session only ... Analogous to an Item in the Cart. Represents one row in a database ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 37
Provided by: Raz96
Category:

less

Transcript and Presenter's Notes

Title: Enterprise JavaBeans Overview


1
Enterprise JavaBeans Overview
  • Presented by
  • Eric Gudgion

2
What are EJBs
  • Enterprise JavaBeans are a server side standards
    based component model.
  • Provides a frame work for methods, naming,
    transactions, security, persistence, life-cycle.
  • Concentrate on business logic.
  • Scalable architecture.

3
Why Business Components?
  • Separate Business Logic from Plumbing and Glue
  • Separate Component Development from Assembly and
    Deployment
  • Manage Software as Depreciable Business Assets
  • Offer easy integration with business components
    and enterprise data
  • Enable portability across platforms

4
What are Enterprise JavaBeans (EJB)?
An EJB defines a component model for developing
and deploying Server-Side business objects.
  • CHARACTERISTICS
  • A Server-Side business Component
  • Written in 100 Java
  • Distributed over a network
  • Always called by a Client
  • Transactional
  • Secure
  • Two Types (Entity and Session)

5
The Right Bean For the Job
DBMS
  • Enterprise JavaBeans
  • Distributed Components for assembling networked
    applications
  • Server-side
  • No GUI
  • Core features methods, naming, transactions,
    security, persistence, life-cycle
  • Separates business logic container
  • JavaBeans
  • Components for assembling local application
  • Generally client-side
  • Often GUI-oriented
  • Core features methods, properties, events,
    introspection, customization
  • Separates design runtime environments

6
Architecture
7
Technical View of an EJB Session(Analogy
Collect Phone Call)
8
Session and Entity Beans
9
Client side
// lookup home from JNDI AccountHome home
(AccountHome) jndiCtx.lookup("bank.accounts")
Account myAccount home.create(...) Account
momsAccount home.findByPrimaryKey() tx.begin
() momsAccount.withdraw(5000) myAccount.deposit(
5000) tx.commit()
10
State Management Persistence
11
Compare the 2 Types of EJBs
Session EJB
Entity EJB
  • Analogous to a Shopping Cart
  • Represents one User connection
  • Can be Stateless (ex. simple query) or Stateful
    (more typical for shopping cart)
  • Exists for life of Session only
  • Not Persistent destroyed if server crashes
  • Contains Business Logic
  • May or may not be Transactional
  • Analogous to an Item in the Cart
  • Represents one row in a database
  • Purely Stateful (represents the data)
  • Exists beyond the Session
  • Persistent
  • Contains Business Logic
  • May or may not be Transactional

12
EJB Taxonomy
Enterprise JavaBeans
Entity Beans Component view of DB row or
object May be long-lived Primary key,
stateful 1-to-many relationship to
client(s) E.g., Customer, Order
  • Session Beans
  • TPM/OTM style
  • Short-lived, no key
  • 1-to-1 relationship to client
  • Explicit DB access
  • E.g., Bank Teller, E-Commerce
    Server

Many EJB applications will use both!
Entity Beans
Session Beans
(via explicit JDBC when automated tools are
insufficient)
(Web shopping cart)
(Inventory agent)
(via O/R mapping)
Stateful
Stateless
Bean- Managed
Container- Managed
13
Persistence
  • Container (typically) handles object persistence
    automatically.
  • Bean written is backing store independent.
  • Containers for SQL DBMS, OODBMS, ORDBMS, file
    system, directory service.
  • Deployment Descriptor properties hold
    container-specific persistence properties, like
    attribute-column mappings.

14
Bean References
15
Persistence DD Wizard Pane
16
Persistence Deployment Descriptor
  • (persistentStoreProperties
  • persistentStoreType jdbc
  • (jdbc
  • tableName ejbAccounts
  • dbIsShared false
  • poolName ejbPool
  • driverName weblogic.jdbc.jts.Driver
  • (attributeMap
  • EJBean attribute Database column
    name
  • -------------------------------------
    ----
  • accountId id
  • balance bal
  • ) end attributeMap
  • ) end jdbc
  • )

17
Transactions
18
Transactional Definition (ACID)
  • Atomic, transactions are all or nothing, never
    incomplete.
  • Consistent, always leave the system in a
    consistent state.
  • Isolated, execute in a safe manner, without
    effecting each other.
  • Durable, once completed and committed, survive a
    system failure.

19
Transaction Management
  • Uses Java Transaction Service (JTS).
  • EJB Server handles TX ID propagation.
  • Declarative TX management through Deployment
    Descriptor
  • Per-method and Bean-wide scope.
  • EJB Container performs TX begin, commit, and
    rollback, and provides 2PC semantics on beans
    behalf.

20
Transaction Control Descriptors
  • TX_NOT_SUPPORTED - Bean does not have
    transactions
  • any active transactions are suspended during
    method call.
  • TX_REQUIRED - Transaction scope required, one is
    created if the scope does not exist.
  • TX_SUPPORTS - If the client has transaction scope
    the bean will use it, otherwise no scope is used.
  • TX_REQUIRES_NEW - Container creates new
    transaction.
  • TX_MANDATORY - Transaction scope always required.
  • TX_BEAN_MANAGED - Bean will manage its scope.

21
Isolation Level Description
  • TRANSACTION_READ_UNCOMMITTED - Can read
    uncommitted data.
  • TRANSACTION_READ_COMMITTED - Cant read
    uncommitted data.
  • TRANSACTION_REPEATABLE_READ - Cant change data
    thats being read by another transaction.
  • TRANSACTION_SERIALIZABLE - Transaction has
    exclusive read and update privileges.

22
Transaction DD Wizard Pane
23
Transaction DD
  • (controlDescriptors
  • (DEFAULT
  • isolationLevel TRANSACTION_SERIALIZABLE
  • transactionAttribute TX_MANDITORY
  • )
  • (buy
  • isolationLevel TRANSACTION_SERIALIZABLE
  • transactionAttribute TX_REQUIRED
  • ) end buy
  • ) end controlDescriptors

24
Security
25
EJB Security Management
  • EJB Server propagates security context.
  • Declarative security attributes in DD.
  • Access control per-method and bean-wide
  • SetUID functionality RunAsMode and
    RunAsIdentity
  • Container enforces access control and sets beans
    identity as described in DD

26
WebLogic Real-World Security
  • SSL protocol
  • RSA Encryption
  • X.509 Digital certificates
  • Access Control List functionality
  • Integrated with leading Internet security vendors

27
Access Control DD Wizard Pane
28
Deployment
29
EJB Packaging
  • EJB Jar file contains
  • Deployment Descriptor (Serializable Entity or
    Session Java Class)
  • Beans Home Remote Interfaces
  • Beans Home Class Names
  • Beans Implementation Code
  • Environmental Properties
  • Access Control Lists
  • Transaction Control Descriptors
  • Manifest File (Declares Descriptor as Bean)
  • All Handled by Server Vendor!

30
Deployment Descriptor
(EntityDescriptor beanHomeName
bank.accounts enterpriseBeanClassName
AccountBean homeInterfaceClassName
AccountHome remoteInterfaceClassName Account
)
31
Summary
32
Development Deployment Roles
  • EJB provider (domain expert) writes bean
  • Application assembler combines beans into a
    system
  • Deployer knows a specific EJB environment
    (server container) BEA WebLogic
  • EJB Server provider BEA WebLogic
  • EJB Container provider BEA WebLogic partners
  • System Administrator runs the EJB Server

Vendor-independent role
33
EJB Benefits
  • Concentrate on business logic.
  • Higher-level semantics security, transactions,
    persistence, naming.
  • Component System-Independent Components.
  • Component roles bean writer, deployer,
    server,container.
  • Scalable architecture.

34
Helpful Tools
  • StructureBuilder - www.webgain.com
  • Rational Rose - www.rational.com
  • Introscope - www.wilytech.com
  • Visual Café - www.webgain.com
  • Visual Age - www-4.ibm.com/software/ad/vjava

35
Useful Books
  • Title Enterprise JavaBeans
  • Publisher OReilly ISBN 1-556592-605-6
  • Author Richard Monson-Haefel
  • Title Java Enterprise in a Nutshell
  • Publisher OReilly ISBN 1-56592-483-5
  • Author David Flanagan, Jim Farley, William
    Crawford Kirs Magnusson
  • Title Mastering Enterprise JavaBeans and the
    Java 2 Platform Enterprise Edition
  • Publisher Wiley ISBN 0-471-33229-1
  • Author Ed Roman

36
Internet Resources
  • http//www.bea.com
  • http//java.sun.com/products/ejb
  • http//www.ejbnow.com
  • http//www.jguru.com
  • http//www.javadevelopersjournal.com
  • news//www4.weblogic.com/weblogic.developer.intere
    st.ejb
Write a Comment
User Comments (0)
About PowerShow.com