Home Page Icon
Home Page
Table of Contents for
Enterprise JavaBeans, 3rd Edition
Close
Enterprise JavaBeans, 3rd Edition
by Richard Monson-Haefel
Enterprise JavaBeans, Third Edition
Enterprise JavaBeans, 3rd Edition
Dedication
Preface
Author’s Note
What Is Enterprise JavaBeans?
Who Should Read This Book?
Organization
Software and Versions
Example Workbooks
Conventions
Comments and Questions
Acknowledgments
1. Introduction
Setting the Stage
Distributed Objects
Server-Side Components
Component Transaction Monitors
Enterprise JavaBeans Defined
Distributed Object Architectures
Rolling Your Own Distributed Object
Component Models
Component Transaction Monitors
Transaction Processing Monitors
Object Request Brokers
CTMs: The Hybrid of ORBs and TP Monitors
Analogies to Relational Databases
CTMs and Server-Side Component Models
Microsoft’s .NET Framework
EJB and CORBA CTMs
Benefits of a Standard Server-Side Component Model
EJB 2.0: Asynchronous Messaging
Java Message Service
Message-driven beans
Titan Cruises: An Imaginary Business
What’s Next?
2. Architectural Overview
The Enterprise Bean Component
Classes and Interfaces
Naming conventions
The remote interface
The remote home interface
EJB 2.0: The bean class
EJB 1.1: The bean class
EJB 2.0 and 1.1: The bean class
The primary key
What about session beans?
EJB 2.0: What about message-driven beans?
Deployment Descriptors and JAR Files
EJB 2.0: Deployment descriptor
EJB 1.1: Deployment descriptor
EJB 2.0 and 1.1: Elements of the XML deployment descriptor
EJB Objects and EJB Home
The EJB object
The EJB home
Deploying a bean
Using Enterprise Beans
Getting Information from an Entity Bean
Modeling Workflow with Session Beans
Stateless and stateful session beans
EJB 2.0: Accessing EJB with Message-Driven Beans
The Bean-Container Contract
The Container-Server Contract
Summary
3. Resource Management and the Primary Services
Resource Management
Instance Pooling
The entity bean life cycle
Overview of state transitions
Instance swapping
EJB 2.0: Message-driven beans and instance pooling
The Activation Mechanism
Primary Services
Concurrency
Concurrency with session and entity beans
Reentrance
EJB 2.0: Concurrency with message-driven beans
Transactions
Persistence
Object-to-relational persistence
Object database persistence
Legacy persistence
Distributed Objects
EJB 2.0: Asynchronous Enterprise Messaging
Naming
Security
Role-driven access control
EJB 2.0: Unchecked methods
EJB 2.0: The runAs security identity
EJB 2.0: Primary Services and Interoperability
What’s Next?
4. Developing Your First Enterprise Beans
Choosing and Setting Up an EJB Server
Setting Up Your Java IDE
Developing an Entity Bean
Cabin: The Remote Interface
CabinHome: The Remote Home Interface
CabinBean: The Bean Class
EJB 2.0: The CabinBean class
EJB 1.1: The CabinBean class
EJB 2.0 and 1.1: The callback methods
The Deployment Descriptor
EJB 2.0: The Cabin EJB’s deployment descriptor
EJB 1.1: The Cabin EJB’s deployment descriptor
EJB 2.0 and 1.1: Defining the XML elements
cabin.jar: The JAR File
Creating a CABIN Table in the Database
Deploying the Cabin EJB
Creating a Client Application
Creating a new Cabin EJB
Developing a Session Bean
TravelAgentRemote: The Remote Interface
TravelAgentHomeRemote: The Remote Home Interface
TravelAgentBean: The Bean Class
The TravelAgent EJB’s Deployment Descriptor
EJB 2.0: Deployment descriptor
EJB 1.1: Deployment descriptor
EJB 2.0 and 1.1: Defining the XML elements
Deploying the TravelAgent EJB
Creating a Client Application
5. The Client View
Locating Beans with JNDI
The Remote Client API
Java RMI-IIOP
Java RMI return types, parameters, and exceptions
Return types and parameters
Exceptions
Java RMI-IIOP type restrictions
Explicit narrowing using PortableRemoteObject
The Remote Home Interface
Removing beans
Bean metadata
The HomeHandle
Creating and finding beans
EJB 2.0: Home methods
The Remote Interface
EJBObject, Handle, and Primary Key
Getting the EJBHome
Primary key
Comparing beans for identity
Removing beans
The enterprise bean Handle
HomeHandle
Inside the Handle
EJB 2.0: The Local Client API
The Local Interface
The Local Home Interface
Deployment Descriptor
Using the Local Client API
When to Use Local Component Interfaces
Are Local Component Interfaces Necessary?
6. EJB 2.0 CMP: Basic Persistence
Overview
The Abstract Programming Model
Abstract Persistence Schema
Container Tools and Persistence
The Customer EJB
The Customer Table
The CustomerBean
The Remote Interface
The Remote Home Interface
The XML Deployment Descriptor
The EJB JAR File
Deployment
The Client Application
Persistence Fields
Dependent Value Classes
Relationship Fields
7. EJB 2.0 CMP: Entity Relationships
The Seven Relationship Types
Abstract Persistence Schema
Database Modeling
One-to-One Unidirectional Relationship
Relational database schema
Abstract programming model
Abstract persistence schema
One-to-One Bidirectional Relationship
Relational database schema
Abstract programming model
Abstract persistence schema
One-to-Many Unidirectional Relationship
Relational database schema
Abstract programming model
Abstract persistence schema
The Cruise, Ship, and Reservation EJBs
Many-to-One Unidirectional Relationship
Relational database schema
Abstract programming model
Abstract persistence schema
One-to-Many Bidirectional Relationship
Relational database schema
Abstract programming model
Abstract persistence schema
Many-to-Many Bidirectional Relationship
Relational database schema
Abstract programming model
Abstract persistence schema
Many-to-Many Unidirectional Relationship
Relational database schema
Abstract programming model
Abstract persistence schema
Co-location and the Deployment Descriptor
Cascade Delete and Remove
8. EJB 2.0 CMP: EJB QL
Declaring EJB QL
The Query Methods
Find Methods
Select Methods
EJB QL Examples
Simple Queries
Simple Queries with Paths
The IN Operator
Using DISTINCT
The WHERE Clause and Literals
The WHERE Clause and Input Parameters
The WHERE Clause and Operator Precedence
The WHERE Clause and CDATA Sections
The WHERE Clause and Arithmetic Operators
The WHERE Clause and Logical Operators
The WHERE Clause and Comparison Symbols
The WHERE Clause and Equality Semantics
The WHERE Clause and BETWEEN
The WHERE Clause and IN
The WHERE Clause and IS NULL
The WHERE Clause and IS EMPTY
The WHERE Clause and MEMBER OF
The WHERE Clause and LIKE
The WHERE Clause and Functional Expressions
Problems with EJB QL
The OBJECT( ) Operator
The Missing ORDER BY Clause
Lack of Support for Date
Limited Functional Expressions
9. EJB 1.1 CMP
A Note for EJB 2.0 Readers
Overview for EJB 1.1 Readers
Container-Managed Persistence
The Remote Interface
The Remote Home Interface
The find methods
The Primary Key
The ShipBean Class
Implementing the javax.ejb.EntityBean Interface
The Create Methods
ejbCreate( ) and ejbPostCreate( )
Using ejbLoad( ) and ejbStore( ) in container-managed beans
Deployment Descriptor
10. Bean-Managed Persistence
The Remote Interface
Set and Get Methods
The Remote Home Interface
The Primary Key
The ShipBean
Obtaining a Resource Connection
Exception Handling
The ejbCreate( ) Method
The ejbLoad( ) and ejbStore( ) Methods
The ejbRemove( ) Method
The ejbFind( ) Methods
The Deployment Descriptor
11. The Entity-Container Contract
The Primary Key
Single-Field Primary Keys
Compound Primary Keys
Undefined Primary Keys
The Callback Methods
setEntityContext( ) and unsetEntityContext( )
ejbCreate( )
ejbCreate( ) and ejbPostCreate( ) Sequence of Events
Using ejbLoad( ) and ejbStore( ) in Container-Managed Persistence
Using ejbLoad( ) and ejbStore( ) in Bean-Managed Persistence
ejbPassivate( ) and ejbActivate( )
ejbRemove( )
EJB 2.0: ejbHome( )
EntityContext
EJBContext
JNDI ENC
The Life Cycle of an Entity Bean
Does Not Exist
The Pooled State
The Ready State
Transitioning from the Pooled state to the Ready state via creation
Transitioning from the Pooled state to the Ready state via a query method
Transitioning from the Pooled state to the Ready state via activation
Transitioning from the Ready state to the Pooled state via passivation
Transitioning from the Ready state to the Pooled state via removal
Life in the Ready State
End of the Life Cycle
12. Session Beans
The Stateless Session Bean
The ProcessPayment EJB
PAYMENT: The database table
ProcessPaymentRemote: The remote interface
Dependent objects: The CreditCardDO and CheckDO classes
PaymentException: An application exception
ProcessPaymentHomeRemote: The home interface
ProcessPaymentBean: The bean class
JNDI ENC: Accessing environment properties
EJBContext
The ProcessPayment EJB’s deployment descriptor
EJB 2.0: Local component interfaces
The Life Cycle of a Stateless Session Bean
Does Not Exist
The Method-Ready Pool
Transitioning to the Method-Ready Pool
Life in the Method-Ready Pool
Transitioning out of the Method-Ready Pool: The death of a stateless bean instance
The Stateful Session Bean
EJB 2.0: Getting Set Up for the TravelAgent EJB
EJB 1.1: Getting Set Up for the TravelAgent EJB
The TravelAgent EJB
TravelAgent: The remote interface
Dependent object: TicketDO
TravelAgentHomeRemote: The home interface
Taking a peek at the client view
TravelAgentBean: The bean class
JNDI ENC and EJB references
Remote EJB references in the JNDI ENC
EJB 2.0: Local EJB references in the JNDI ENC
The bookPassage( ) method
Why use a Reservation entity bean?
listAvailableCabins( ): Listing behavior
EJB 2.0: The TravelAgent deployment descriptor
EJB 1.1: The TravelAgent deployment descriptor
The Life Cycle of a Stateful Session Bean
Does Not Exist State
Method-Ready State
Transitioning to the Method-Ready state
Life in the Method-Ready state
Transitioning out of the Method-Ready state
Passivated State
System exceptions
13. Message-Driven Beans
JMS as a Resource
Reimplementing the TravelAgent EJB with JMS
TopicConnectionFactory and Topic
TopicConnection and TopicSession
TopicPublisher
Message types
XML deployment descriptor
JMS application client
JMS Is Asynchronous
JMS Messaging Models: Publish-and-Subscribe and Point-to-Point
Publish-and-subscribe
Point-to-point
Which messaging model should you use?
Entity and Session Beans Should Not Receive Messages
Learning More About JMS
Message-Driven Beans
The ReservationProcessor EJB
The ReservationProcessorBean Class
MessageDrivenBean interface
MessageDrivenContext
MessageListener interface
The onMessage( ) method: Workflow and integration for B2B
Sending messages from a message-driven bean
XML deployment descriptor
<message-selector>
Message selector examples
Managing claims in an HMO
Notification of certain bids on inventory
Selecting recipients for a catalog mailing
<acknowledge-mode>
<message-driven-destination>
The ReservationProcessor clients
The reservation message producer
The ticket message consumer
The Life Cycle of a Message-Driven Bean
Does Not Exist
The Method-Ready Pool
Transitioning to the Method-Ready Pool
Life in the Method-Ready Pool
Transitioning out of the Method-Ready Pool: The death of an MDB instance
14. Transactions
ACID Transactions
Is the TravelAgent EJB Atomic?
Is the TravelAgent EJB Consistent?
Is the TravelAgent EJB Isolated?
Is the TravelAgent EJB Durable?
Declarative Transaction Management
Transaction Scope
Transaction Attributes
Setting a transaction attribute
Transaction attributes defined
EJB 2.0: Container-managed persistence and transaction attributes
EJB 2.0: Message-driven beans and transaction attributes
Transaction Propagation
EJB 2.0: Collection-Based Relationships and Transactions
Isolation and Database Locking
Dirty, Repeatable, and Phantom Reads
Dirty reads
Repeatable reads
Phantom reads
Database Locks
Transaction Isolation Levels
Balancing Performance Against Consistency
Controlling isolation levels
Nontransactional Beans
Explicit Transaction Management
Transaction Propagation in Bean-Managed Transactions
EJB 2.0: TravelAgentBean
EJB 1.1: TravelAgentBean
EJB 2.0: Message-driven beans and bean-managed transactions
Heuristic Decisions
UserTransaction
Status
EJBContext Rollback Methods
Exceptions and Transactions
Application Exceptions Versus System Exceptions
EJB 2.0: bookPassage( ) method
EJB 1.1: bookPassage( ) method
System exceptions
Application exceptions
Transactional Stateful Session Beans
The Transactional Method-Ready State
Transitioning into the Transactional Method-Ready state
Life in the Transactional Method-Ready state
15. Design Strategies
Hash Codes in Compound Primary Keys
Well-Distributed Versus Unique Hash Codes
Passing Objects by Value
EJB 1.1: Dependent Objects
Validation Rules in Dependent Objects
Bulk Accessors for Remote Clients
Rules-of-thumb for bulk accessors
Entity Objects
Improved Performance with Session Beans
Network Traffic and Latency with Remote Clients
Striking a Balance with Remote Clients
Listing Behavior
Implementing lists as arrays of structures
Implementing lists as ResultSets
Bean Adapters
Implementing a Common Interface
Why the Bean Class Should Not Implement the Remote Interface
EJB 2.0: Why the Bean Class Should Not Implement the Local Interface
EJB 1.1: The Business Interface Alternative
Entity Beans Without Create Methods
EJB 1.1: Object-to-Relational Mapping Tools
Avoid Emulating Entity Beans with Session Beans
Direct Database Access from Session Beans
Avoid Chaining Stateful Session Beans
16. XML Deployment Descriptors
What Is an XML Deployment Descriptor?
The Contents of a Deployment Descriptor
The Document Header
The Descriptor’s Body
Describing Enterprise Beans
Session and Entity Beans
Message-Driven Beans
Specifying Primary Keys
Deferring primary key definition
Environment Entries
References to Other Beans
Remote references
EJB 2.0: Local references
References to External Resources
EJB 2.0: Additional administered objects
EJB 2.0: Shareable resources
Security Roles
Declaring EJB QL Elements
EJB 2.0: Describing Relationships
Describing Bean Assembly
Specifying a Bean’s Transaction Attributes
Specifying Security Roles and Method Permissions
Assigning roles to methods
EJB 2.0: Unchecked methods
EJB 2.0: The runAs security identity
EJB 2.0: Exclude list
Identifying Specific Methods
Wildcard declarations
Named method declarations
Specific method declarations
Remote/home/local differentiation
The ejb-jar File
The client-jar File
17. Java 2, Enterprise Edition
Servlets
JavaServer Pages
Web Components and EJB
J2EE Fills in the Gaps
J2EE Application Client Components
Guaranteed Services
Fitting the Pieces Together
Future Enhancements
A. The Enterprise JavaBeans API
Package: javax.ejb
EJB 2.0: AccessLocalException
CreateException
DuplicateKeyException
EJBContext
EJBException
EJBHome
EJB 2.0: EJBLocalHome
EJB 2.0: EJBLocalObject
EJBMetaData
EJBObject
EnterpriseBean
EntityBean
EntityContext
FinderException
Handle
HomeHandle
EJB 2.0: MessageDrivenBean
EJB 2.0: MessageDrivenContext
NoSuchEntityException
ObjectNotFoundException
RemoveException
SessionBean
SessionContext
SessionSynchronization
EJB 2.0: TransactionRequiredLocalException
EJB 2.0: TransactionRolledbackLocalException
EJB 2.0: Package: javax.jms
MessageListener
EJB 2.0: Package: javax.ejb.spi
HandleDelegate
B. State and Sequence Diagrams
Entity Beans
Life Cycle State Diagram of the Entity Bean
Sequence Diagrams for Container-Managed Persistence
Sequence Diagrams for Bean-Managed Persistence
Session Beans
Stateless Session Beans
Stateful Session Beans
Message-Driven Beans
Interactions Between Exceptions and Transactions
C. EJB Vendors
Commercial Products
Open Source Projects
Index
Colophon
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Cover
Next
Next Chapter
Dedication
Enterprise JavaBeans, 3rd Edition
Richard Monson-Haefel
Editor
Mike Loukides
Copyright © 2001 O'Reilly Media, Inc.
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset