Roman Ed, Sriganesh Rima Patel, Brose Gerald
Учебник Mastering Enterprise JavaBeans, Third Edition. Published by Wiley Publishing, Inc. - Indianapolis, 2007. - 841 p.
Part One Overview
Chapter Overview
The Motivation for Enterprise JavaBeans
Component Architectures
Service-Oriented Architectures
Divide and Conquer to the Extreme with Reusable Services
Introducing Enterprise JavaBeans
Why Java?
EJB as a Business Tier Component
The EJB Ecosystem
The Bean Provider
The Application Assembler
The EJB Deployer
The System Administrator
The Container and Server Provider
The Tool Vendors
Summary of Roles
The Java Platform, Enterprise Edition (JEE)
The JEE Technologies
Chapter EJB Fundamentals
Enterprise Beans
Types of Beans
Distributed Objects: The Foundation for EJB
Distributed Objects and Middleware
Explicit Middleware
Implicit Middleware
What Constitutes an Enterprise Bean?
The Enterprise Bean Class
The EJB Object
The Home Object
The Local Interfaces
Deployment Descriptors
Vendor-Specific Files
Ejb-jar File
Summary of Terms
Chapter Writing Your First Bean
How to Develop an EJB Component
The Remote Interface
The Local Interface
The Home Interface
The Local Home Interface
The Bean Class
The Deployment Descriptor
The Vendor-Specific Files
The Ejb-jar File
Deploying the Bean
The Optional EJB Client JAR File
Understanding How to Call Beans
Looking up a Home Object
Running the System
The Server-Side Output
The Client-Side Output
Implementing Component Interfaces
A Solution
Part Two The Triad of Beans
Chapter Introduction to Session Beans
Session Bean Lifetime
Session Bean Subtypes
Stateful Session Beans
Stateless Session Beans
Special Characteristics of Stateful Session Beans
Achieving the Effect of Pooling with Stateful Beans
The Rules Governing Conversational State
Activation and Passivation Callbacks
Method Implementation Summary
A Simple Stateful Session Bean
Life Cycle Diagrams for Session Beans
Chapter Writing Session Bean Web Services
Web Services Concepts
Web Services Standards
XML Artifacts and Platform Independence
Implementing a Web Service
The JAX-RPC Service Endpoint Interface
WSDL and the XML/Java Mapping
Packaging and Deploying a Web Service Session Bean
Implementing a Web Service Client
Chapter Introduction to Entity Beans
Persistence Concepts
Object-Relational Mapping
What Is an Entity Bean?
About the Files That Make Up an Entity Bean
Features of Entity Beans
Entity Beans Survive Failures
Entity Bean Instances Are a View into a Database
Several Entity Bean Instances May Represent the Same
Underlying Data
Entity Bean Instances Can Be Pooled
There Are Two Ways to Persist Entity Beans
Creation and Removal of Entity Beans
Entity Beans Can Be Found
You Can Modify Entity Bean Data without Using EJB
Entity Contexts
getEJBLocalObject() / getEJBObject()
getPrimaryKey()
Chapter Writing Bean-Managed Persistent Entity Beans
Entity Bean Coding Basics
Finding Existing Entity Beans: Finder Methods
Bean-Managed Persistence Example: A Bank Account
Account.java
AccountLocal.java
AccountHome.java
AccountLocalHome.java
AccountPK.java
AccountBean.java
AccountException.java
Client.java
The Deployment Descriptor
The Container-Specific Deployment Descriptor
Setting up the Database
Running the Client Program
Server-Side Output
Client-Side Output
Putting It All Together: Walking through a
BMP Entity Bean's Life Cycle
Chapter Writing Container-Managed Persistent Entity Beans
Features of CMP Entity Beans
CMP Entity Beans Are Subclassed
CMP Entity Beans Have No Declared Persistent Fields
CMP Get/Set Methods Are Defined in the Subclass
CMP Entity Beans Have an Abstract Persistence Schema
CMP Entity Beans Have a Query Language
CMP Entity Beans Can Have ejbSelect() Methods
Implementation Guidelines for Container-Managed Persistence
Container-Managed Persistence Example: A Product Line
Product.java
ProductLocal.java
ProductHome.java
ProductLocalHome.java
ProductPK.java
ProductBean.java
The Deployment Descriptor
The Container-Specific Deployment Descriptor
Client, Java
Running the Client Program
The Life Cycle of a CMP Entity Bean
Chapter Introduction to Message-Driven Beans
Motivation to Use Message-Driven Beans
The Java Message Service
Messaging Domains
TheJMSAPI
Integrating JMS with EJB
What Is a Message-Driven Bean?
Developing Message-Driven Beans
The Semantics
A Simple Example
Advanced Concepts
JMS Message-Driven Bean Gotchas
Message Ordering
Missed ejbRemoveO Calls
Poison Messages
How to Return Results Back to Message Producers
The Future: Asynchronous Method Invocations
Chapter Adding Functionality to Your Beans
Calling Beans from Other Beans
Default JNDI Lookups
Understanding EJB References
Resource Factories
Environment Properties
Understanding Handles
Home Handles
Part Three Advanced Enterprise JavaBeans Concepts
Chapter EJB Best Practices
When to Use EJB
How to Choose a Web Application Framework to Work with EJB
Applying Model Driven Development in EJB Projects
Applying Extreme Programming in EJB Projects
Testing EJB
EJB Unit Testing
Use Frameworks for EJB Unit Testing
Implementing Client-Side Callback Functionality in EJB
JMS
Remote Method Invocation
Web Service
Choosing Between Servlets and Stateless Session Beans
as Service Endpoints
Considering the Use of Aspect-Oriented Programming
Techniques in EJB Projects
Aspect-Oriented Programming
When to Use AOP in EJB Applications
Reflection, Dynamic Proxy, and EJB
Deploying EJB Applications to Various Application Servers
Debugging EJB
Inheritance and Code Reuse in EJB
Writing Singletons in EJB
When to Use XML with EJB
When to Use Messaging Versus RMI-IIOP
Chapter Transactions
Motivation for Transactions
Atomic Operations
Network or Machine Failure
Multiple Users Sharing Data
Benefits of Transactions
The ACID Properties
Transactional Models
Flat Transactions
Nested Transactions
Other Transactional Models
Enlisting in Transactions with Enterprise JavaBeans
Underlying Transaction System Abstraction
Declarative, Programmatic, and Client-Initiated Transactions
Choosing a Transaction Style
Container-Managed Transactions
EJ В Transaction Attribute Values
Programmatic Transactions in EJB
CORBA Object Transaction Service
The Java Transaction Service
The Java Transaction API
Declarative versus Programmatic Transactions Example
Transactions from Client Code
Transactional Isolation
The Need for Concurrency Control
The Dirty Read Problem
The Unrepeatable Read Problem
The Phantom Problem
Transaction Isolation Summary
Isolation and EJB
Pessimistic and Optimistic Concurrency Control
Distributed Transactions
Durability and the Two-Phase Commit Protocol
The Transactional Communications Protocol
and Transaction Contexts
Designing Transactional Conversations in EJB
JEE Transaction Service and Extended Transactions
Chapter Security
Violations, Vulnerabilities, and Risk
Controls
Web Application Security
Authentication in Web Applications
Authorization
Confidentiality and Integrity
Understanding EJB Security
Authentication in EJB
Authorization in EJB
Security Propagation
Secure Interoperability
IIOP/SSL
CSIv
Web Services Security
End-to-End Security
XML Digital Signature and XML Encryption
SAML
WS-Security
Chapter EJB Timers
Scheduling
EJB and Scheduling
The EJB Timer Service
Timer Scrvice API
Interaction between the EJB and the Timer Service
Timer Example: CleanDayLimitOrdersEJB
The CleanDayLimitOrders EJB Remote Interface
The CleanDayLimitOrders EJB Bean Class
The CleanDayLimitOrders EJB Home Interface
The CleanDayLimitOrders EJB Deployment Descriptor
The CleanDayLimitOrders EJB Client
Running the Client
Strengths and Limitations of EJB Timer Service
Chapter BMP and CMP Relationships
The CMP and BMP Difference
Cardinality
: Relationships
:N Relationships
M:N Relationships
Directionality
Implementing Directionality with BMP
Implementing Directionality with CMP
Directionality May Not Map to Database Schemas
Bidirectional or Unidirectional?
Lazy Loading
Aggregation Versus Composition and Cascading Deletes
Relationships and EJB-QL
Recursive Relationships
Circular Relationships
Referential Integrity
Relationships, Referential Integrity, and Client Code
Chapter Persistence Best Practices
Comparing Entity Beans with Other Persistence Approaches
Control
Data retrieval
Procedural versus Object-Oriented
Caching
Enforcement of Schema Independence
Migration
Rapid Application Development
Choosing Between CMP and BMP
Code Reduction and Rapid Application Development
Performance
Bugs
Control
Application Server and Database Independence
Relationships
Learning Curve and Cost
Choosing the Right Granularity for Entity Beans
Persistence Tips and Tricks
Beware the Object-Relational Impedance Mismatch
Hard-Coded versus Soft-Coded SQL
When to Use Stored Procedures
Normalizing and Denormalizing
Use Your EJB Object Model to Drive Your Data Model
Follow a Good Data Design Process
Use Surrogate Keys
Understand the Impacts of Database Updates
Versioning EJB Components
Living with a Legacy Database Design
Handling Large Result Sets
Chapter EJB Integration
Why Does Integration Matter?
Integration Styles
EJB and Integration
JEE Connector Architecture
Why JEE Connectors?
Resource Adapter Interaction with JEE Components
Resource Adapter Interaction with Application Server
The JEE Connector API
The javax.resource Package
The javax.resource.cci Package
The javax.resource.spi Package
The javax.resource.spi.endpoint Package
The javax.resource.spi.security Package
The javax.resource.spi.work Package
System Contracts
Lifecycle Management
Connection Management
Security Management
Transaction Management
Work Management
Message In-flow
Connector Example: OutboundLoanRA
Example Architecture
JavaLoanApp.java
LoanApp.dll
OutboundLoanRA
LoanRatesEJB
LoanRatesClient
Running the Client
Extending OutboundLoanRA
Integration Best Practice: When to Use Which Technology
When to Use JMS and JMS-Based MDB
When to Use JEE Connectors
When to Use Java Web Services
Chapter EJB Performance Optimizations
It Pays to Be Proactive!
The Stateful Versus Stateless Debate from a
Performance Point of View
How to Guarantee a Response Time with Capacity Planning
Use Session Facade for Better Performance
Choosing Between Local Interfaces and Remote Interfaces
Partitioning Your Resources
Tuning Stateless Session Beans
Tuning Stateful Session Beans
Tuning Entity Beans
Tuning Message-Driven Beans
Tuning Java Virtual Machine
Miscellaneous Tuning Tips
Choosing the Right EJB Server
Chapter Clustering
Overview of Large-Scale Systems
What Is a Large-Scale System?
Basic Terminology
Partitioning Your Clusters
Instrumenting Clustered EJBs
How EJBs Can Be Clustered
The Concept of Idempotence
Stateless Session Bean Clustering
Stateful Session Bean Clustering
Entity Bean Clustering
Message-Driven Bean Clustering
Other EJB Clustering Issues
First Contact
Initial Access Logic
Chapter Starting Your EJB Project on the Right Foot
Get the Business Requirements Down
Decide Whether JEE Is the Right Choice
Staff Your Project
Design Your Complete Object Model
Implement a Single Vertical Slice
Choose an Application Server
Divide Your Team
Invest in Tools
Invest in a Standard Build Process
Next Steps
Chapter Choosing an EJB Server
JEE Standard Compliance
Pluggable JRE
Conversion Tools
Complex Mappings
Third-Party JDBC Driver Support
Lazy Loading
Deferred Database Writes
Pluggable Persistence Providers
In-Memory Data Cache
Integrated Tier Support
Scalability
High Availability
Security
IDE Integration
UML Editor Integration
Intelligent Load Balancing
Stateless Transparent Fail-over
Clustering
Java Management Extension (JMX)
Administrative Support
Hot Deployment
Instance Pooling
Automatic EJB Generation
Clean Shutdown
Real-Time Deployment
Distributed Transactions
Superior Messaging Architecture
Provided EJB Components
Web Services
Workflow
Open Source
Specialized Services
Nontechnical Criteria
Chapter EJB-JEE Integration: Building a Complete Application
The Business Problem
A Preview of the Final Web Site
Scoping the Technical Requirements
The Business Logic Tier
The Presentation Tier
Example Code
Appendix A RM-IIP and JNDI Tutorial
Appendix В CORBA Interoperability
Appendix С Deployment Descriptor Reference
Appendix D The EJB Query Language (EJB-QL)
Appendix E EJB Quick Reference Guide