Home Page Icon
Home Page
Table of Contents for
Dedication
Close
Dedication
by Richard Monson-Haefel
Enterprise JavaBeans, Second Edition
Enterprise JavaBeans, 2nd Edition
Dedication
Preface
What Is Enterprise JavaBeans?
Who Should Read This Book?
Organization
Software and Versions
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
TP Monitors
Object Request Brokers
CTMs: The Hybrid of ORBs and TP Monitors
Analogies to Relational Databases
CTMs and Server-Side Component Models
MTS
EJB and CORBA CTMs
Benefits of a Standard Server-Side Component Model
Titan Cruises: An Imaginary Business
What’s Next?
2. Architectural Overview
The Enterprise Bean Component
Classes and Interfaces
The remote interface
The home interface
The bean class
The primary key
What about session beans?
Deployment Descriptors and JAR Files
EJB 1.0: Deployment descriptors
EJB 1.1: Deployment descriptors
The Unseen Pieces
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
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
The Activation Mechanism
Primary Services
Concurrency
Reentrance
Transactions
Persistence
Object-to-relational persistence
Object database persistence
Legacy persistence
Distributed Objects
Naming
Security
EJB 1.1: Role-driven access control
EJB 1.0: Method-driven access control
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 Home Interface
CabinPK: The Primary Key
CabinBean: The Bean Class
EJB 1.1: The Deployment Descriptor
EJB 1.0: The Deployment Descriptor
cabin.jar: The JAR File
EJB 1.1: Packaging the Cabin bean
EJB 1.0: Packaging the Cabin bean
Creating a CABIN Table in the Database
Deploying the Cabin Bean
EJB 1.1 deployment tools
EJB 1.0 deployment tools
Creating a Client Application
EJB 1.1: Obtaining a remote reference to the home interface
EJB 1.0: Obtaining a remote reference to the home interface
Creating a new Cabin bean
Developing a Session Bean
TravelAgent: The Remote Interface
TravelAgentHome: The Home Interface
TravelAgentBean: The Bean Class
EJB 1.1: TravelAgentBean
EJB 1.0: TravelAgentBean
EJB 1.1: TravelAgent Bean’s Deployment Descriptor
EJB 1.0: The TravelAgent Beans’ Deployment Descriptor
EJB 1.1: The JAR File
EJB 1.0: The JAR File
Deploying the TravelAgent Bean
Creating a Client Application
5. The Client View
Locating Beans with JNDI
The EJB Client-Side API
EJB 1.1: Java RMI-IIOP Conformance Requirement
EJB 1.1 and 1.0: The Java RMI Programming Model
EJB 1.1: Java RMI-IIOP type restrictions
EJB 1.1: Explicit narrowing using PortableRemoteObject
The Home Interface
Removing beans
Bean metadata
EJB 1.1: The HomeHandle
Creating and finding beans
The Remote Interface
EJBObject, Handle, and Primary Key
Getting the EJBHome
Primary key
Comparing beans for identity
Removing beans
The bean handle
EJB 1.1: HomeHandle
Inside the Handle
6. Entity Beans
Container-Managed Persistence
The Remote Interface
Set and get methods
The Primary Key
Compound primary keys
Single-field key
EJB 1.1: Undefined primary keys
The Home Interface
The find methods
Java RMI Return Types, Parameters, and Exceptions
The ShipBean Class
Implementing the javax.ejb.EntityBean Interface
The EntityContext
The Create Methods
ejbCreate( )
ejbPostCreate( )
ejbCreate() and ejbPostCreate( ) sequence of events
Using ejbLoad() and ejbStore( ) in container-managed beans
EJB 1.1: Deploying the ShipBean
EJB 1.0: Deploying the ShipBean
The Client Application
Bean-Managed Persistence
Making the ShipBean a Bean-Managed Entity
Exception Handling
EntityContext
EJB 1.1: EJBContext
EJB 1.0: EJBContext
Obtaining a Connection to the Database
EJB 1.1: Using JDBC in EJB
EJB 1.0: Using JDBC in EJB
The ejbCreate( ) Method
The ejbLoad( ) and ejbStore( ) Methods
The ejbRemove( ) Method
ejbFind( ) Methods
EJB 1.1: Deploying the Bean-Managed Ship Bean
EJB 1.0: Deploying the Bean-Managed Ship Bean
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 find 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
7. Session Beans
The Stateless Session Bean
Downloading the Missing Pieces
The ProcessPayment Bean
PAYMENT: The database table
ProcessPayment: The remote interface
Dependent classes: The CreditCard and Check classes
PaymentException: An application exception
ProcessPaymentHome: The home interface
ProcessPaymentBean: The bean class
EJB 1.1: Accessing environment properties
EJB 1.1: EJBContext
EJB 1.1: The ProcessPayment bean’s deployment descriptor
EJB 1.0: The ProcessPayment bean’s deployment descriptor
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
The TravelAgent Bean
TravelAgent: The remote interface
TravelAgentHome: The home interface
Taking a peek at the client view
TravelAgentBean: The bean class
Why use a Reservation entity bean?
listAvailableCabins( ): Listing behavior
EJB 1.1: The TravelAgent deployment descriptor
EJB 1.0: The TravelAgent deployment descriptor
The Life Cycle of a Stateful Session Bean
Does Not Exist
The Method-Ready State
Transitioning to the Method-Ready state
Life in the Method-Ready state
Transitioning out of the Method-Ready state
EJB 1.1 timeouts
EJB 1.0 timeouts
Passivated State
EJB 1.1 system exceptions
8. Transactions
ACID Transactions
Is the TravelAgent Bean Atomic?
Is the TravelAgent Bean Consistent?
Is the TravelAgent Bean Isolated?
Is the TravelAgent Bean Durable?
Declarative Transaction Management
Transaction Scope
Transaction Attributes
EJB 1.1: Setting a transaction attribute
EJB 1.0: Setting a transaction attribute
Transaction Attributes Defined
Transaction Propagation
Isolation and Database Locking
Dirty, Repeatable, and Phantom Reads
Dirty reads
Repeatable reads
Phantom reads
Database Locks
Transaction Isolation Levels
EJB 1.1 transaction isolation control
EJB 1.0 transaction isolation control
Balancing Performance Against Consistency
EJB 1.1: Controlling isolation levels
EJB 1.0: Controlling isolation levels
Non-Transactional Beans
Explicit Transaction Management
Transaction Propagation in Bean-Managed Transactions
Heuristic Decisions
UserTransaction
Status
EJBContext Rollback Methods
EJB 1.1: Exceptions and Transactions
Application Exceptions Versus System Exceptions
System exceptions
Application exceptions
EJB 1.0: Exceptions and Transactions
Container-Initiated Transactions
Client-Initiated Transactions
Bean-Managed Transactions
Unchecked Exceptions
Transactional Stateful Session Beans
The Transactional Method-Ready State
Transitioning into the Transactional Method-Ready state
Life in the Transactional Method-Ready state
9. Design Strategies
Hash Codes in Compound Primary Keys
Well-Distributed Versus Unique Hash Codes
Passing Objects by Value
Dependent Objects
Validation Rules in Dependent Objects
Bulk Accessors
Rules-of-thumb for bulk accessors
Entity Objects
Improved Performance with Session Beans
Network Traffic and Latency
Resource Consumption
Striking a Balance
Listing Behavior
Implementing lists as arrays of structures
Implementing lists as ResultSets
Bean Adapters
Implementing a Common Interface
Why the Bean Class Shouldn’t Implement the Remote Interface
The Business Interface Alternative
Entity Beans Without Create Methods
Entity Bean Relationships
Simple Associations
Maintaining the database mapping
Mapping serializable to VARBINARY
Preserving the primary key
Preserving the handle
Native Java persistence
Complex Entity Relationships
One-to-many database mapping
Mapping serializable to VARBINARY
Native Java persistence
Object-to-Relational Mapping Tools
When Entity Beans Are Not an Option
Emulating Entity Beans with Session Beans
Limiting Session Beans to Workflow
Direct database access with JDBC
Direct access with object-to-relational mapping tools
Avoid Chaining Stateful Session Beans
10. XML Deployment Descriptors
What Is an XML Deployment Descriptor?
The Contents of a Deployment Descriptor
The Document Header
The Descriptor’s Body
Describing Beans
Session and Entity Beans
Specifying Primary Keys
Deferring primary key definition
Environment Entries
References to Other Beans
References to External Resources
Security Roles
Describing Bean Assembly
Specifying a Bean’s Transactional Attributes
Specifying Security Roles and Method Permissions
Assigning roles to methods
Identifying Specific Methods
Wildcard declarations
Named method declarations
Specific method declarations
Remote/home differentiation
The ejb-jar File
The client-jar File
11. Java 2, Enterprise Edition
Servlets
Java Server Pages
Web Components and EJB
J2EE Fills in the Gaps
J2EE Application Client Components
Guaranteed Services
Connectivity and Interoperability
Fitting the Pieces Together
Future Enhancements
A. The Enterprise JavaBeans API
Package: javax.ejb
CreateException
DuplicateKeyException
EJBContext
EJBException (1.1)
EJBHome
EJBMetaData
EJBObject
EnterpriseBean
EntityBean
EntityContext
FinderException
Handle
HomeHandle (1.1)
NoSuchEntityException (1.1)
ObjectNotFoundException
RemoveException
SessionBean
SessionContext
SessionSynchronization
Package: javax.ejb.deployment (EJB 1.0 Only)
AccessControlEntry
ControlDescriptor
DeploymentDescriptor
EntityDescriptor
SessionDescriptor
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
EJB 1.1: Interactions Between Exceptions and Transactions
C. EJB Vendors
Commercial Products
Open Source Projects
D. New Features in EJB 1.1
Entity Beans
Session Beans
XML Deployment Descriptors
The Default JNDI Context
RMI over IIOP Narrowing
Security
Looking Ahead to EJB 2.0
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
Enterprise JavaBeans, 2nd Edition
Next
Next Chapter
Preface
Dedication
For my wife and best friend, Hollie.
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