[轉載]SUN認證:SCBCD教材英文版

This is the specification of the Enterprise JavaBeansTM architecture.The Enterprise JavaBeans architecture is a component architecture for the development and deployment of componentbased distributed business applications. Applications written using the Enterprise JavaBeans architecture are scalable, transactional, and multi-user secure. These applications may be written once, and then deployed on any server platform that supports the Enterprise JavaBeans specification.

Table of Contents
Chapter 1 Introduction……………………………………………………………………………………………………. 25
1.1 Target audience…………………………………………………………………………………… 25
1.2 What is new in EJB 2.0 ……………………………………………………………………….. 25
1.3 Acknowledgments ………………………………………………………………………………. 26
1.4 Organization ………………………………………………………………………………………. 27
1.5 Document conventions ………………………………………………………………………… 28
Chapter 2 Goals ……………………………………………………………………………………………………………… 29
2.1 Overall goals………………………………………………………………………………………. 29
2.2 EJB Releases 1.0 and 1.1……………………………………………………………………… 30
2.3 Goals for Release 2.0…………………………………………………………………………… 30
Chapter 3 EJB Roles and Scenarios ………………………………………………………………………………….. 33
3.1 EJB Roles ………………………………………………………………………………………….. 33
3.1.1 Enterprise Bean Provider ………………………………………………………… 34
3.1.2 Application Assembler……………………………………………………………. 34
3.1.3 Deployer……………………………………………………………………………….. 34
3.1.4 EJB Server Provider ……………………………………………………………….. 35
3.1.5 EJB Container Provider…………………………………………………………… 35
3.1.6 System Administrator …………………………………………………………….. 36
3.2 Scenario: Development, assembly, and deployment ………………………………… 36
Overview……………………………………………………………………………………………………….. 41
4.1 Enterprise Beans as components …………………………………………………………… 41
4.1.1 Component characteristics ………………………………………………………. 41
4.1.2 Flexible component model………………………………………………………. 42
4.2 Enterprise JavaBeans contracts……………………………………………………………… 43
4.2.1 Client-view contracts for session beans and entity beans …………….. 43
4.2.2 Component contract ……………………………………………………………….. 44
4.2.3 Ejb-jar file …………………………………………………………………………….. 46
4.2.4 Contracts summary ………………………………………………………………… 46


4.3 Session, entity, and message-driven objects ……………………………………………. 47
4.3.1 Session objects ………………………………………………………………………. 48
4.3.2 Entity objects…………………………………………………………………………. 48
4.3.3 Message-driven objects …………………………………………………………… 48
4.4 Standard mapping to CORBA protocols ………………………………………………… 49
Chapter 5 Local and Remote Client Views…………………………………………………………………………. 51
5.1 Overview …………………………………………………………………………………………… 51
5.2 Remote Clients …………………………………………………………………………………… 52

Sun Microsystems, Inc.
5.3 Local Clients………………………………………………………………………………………. 52
5.4 Determining the client view………………………………………………………………….. 53
Chapter 6 Client View of a Session Bean …………………………………………………………………………… 55
6.1 Overview……………………………………………………………………………………………. 55
6.2 EJB Container…………………………………………………………………………………….. 56
6.2.1 Locating a session bean’s home interface ………………………………….. 57
6.2.2 What a container provides……………………………………………………….. 57
6.3 Session bean’s remote home interface……………………………………………………. 58
6.3.1 Creating a session object …………………………………………………………. 59
6.3.2 Removing a session object ………………………………………………………. 59
6.4 Session bean’s local home interface ………………………………………………………. 60
6.4.1 Creating a session object …………………………………………………………. 60
6.4.2 Removing a session object ………………………………………………………. 60
6.5 EJBObject and EJBLocalObject……………………………………………………………. 61
6.6 Session object identity …………………………………………………………………………. 62
6.7 Client view of session object’s life cycle………………………………………………… 62
6.7.1 References to session object remote interfaces …………………………… 63
6.7.2 References to session object local interfaces ……………………………… 64
6.8 Creating and using a session object ……………………………………………………….. 64
6.9 Object identity ……………………………………………………………………………………. 65
6.9.1 Stateful session beans……………………………………………………………… 65
6.9.2 Stateless session beans ……………………………………………………………. 66
6.9.3 getPrimaryKey() …………………………………………………………………….. 66
6.10 Type narrowing …………………………………………………………………………………… 67
Chapter 7 Session Bean Component Contract…………………………………………………………………….. 69
7.1 Overview……………………………………………………………………………………………. 69
7.2 Goals …………………………………………………………………………………………………. 70
7.3 A container’s management of its working set………………………………………….. 70
7.4 Conversational state …………………………………………………………………………….. 71
7.4.1 Instance passivation and conversational state……………………………… 71
7.4.2 The effect of transaction rollback on conversational state ……………. 73
7.5 Protocol between a session bean instance and its container ………………………. 73
7.5.1 The required SessionBean interface ………………………………………….. 73
7.5.2 The SessionContext interface …………………………………………………… 74
7.5.3 The optional SessionSynchronization interface…………………………… 74
7.5.4 Business method delegation …………………………………………………….. 75
7.5.5 Session bean’s ejbCreate<METHOD>(…) methods ……………………. 75
7.5.6 Serializing session bean methods……………………………………………… 76
7.5.7 Transaction context of session bean methods …………………………….. 76
7.6 STATEFUL Session Bean State Diagram……………………………………………….. 77
7.6.1 Operations allowed in the methods of a stateful session bean class . 79
7.6.2 Dealing with exceptions ………………………………………………………….. 81
7.6.3 Missed ejbRemove() calls ……………………………………………………….. 82

Sun Microsystems, Inc.
7.6.4 Restrictions for transactions…………………………………………………….. 82
7.7 Object interaction diagrams for a STATEFUL session bean……………………… 82
7.7.1 Notes ……………………………………………………………………………………. 83
7.7.2 Creating a session object…………………………………………………………. 83
7.7.3 Starting a transaction………………………………………………………………. 84
7.7.4 Committing a transaction ………………………………………………………… 85
7.7.5 Passivating and activating an instance between transactions ………… 85
7.7.6 Removing a session object ………………………………………………………. 86
7.8 Stateless session beans ………………………………………………………………………… 87
7.8.1 Stateless session bean state diagram …………………………………………. 88
7.8.2 Operations allowed in the methods of a stateless session bean class 89
7.8.3 Dealing with exceptions………………………………………………………….. 91
7.9 Object interaction diagrams for a STATELESS session bean ……………………. 91
7.9.1 Client-invoked create()……………………………………………………………. 91
7.9.2 Business method invocation…………………………………………………….. 92
7.9.3 Client-invoked remove() …………………………………………………………. 93
7.9.4 Adding instance to the pool …………………………………………………….. 93
7.10 The responsibilities of the bean provider ……………………………………………….. 95
7.10.1 Classes and interfaces …………………………………………………………….. 95
7.10.2 Session bean class ………………………………………………………………….. 95
7.10.3 ejbCreate<METHOD> methods ………………………………………………. 96
7.10.4 Business methods…………………………………………………………………… 96
7.10.5 Session bean’s remote interface ……………………………………………….. 97
7.10.6 Session bean’s remote home interface ………………………………………. 97
7.10.7 Session bean’s local interface…………………………………………………… 98
7.10.8 Session bean’s local home interface………………………………………….. 98
7.11 The responsibilities of the container provider …………………………………………. 99
7.11.1 Generation of implementation classes ………………………………………. 99
7.11.2 Session EJBHome class ………………………………………………………….. 100
7.11.3 Session EJBObject class …………………………………………………………. 100
7.11.4 Session EJBLocalHome class ………………………………………………….. 100
7.11.5 Session EJBLocalObject class …………………………………………………. 100
7.11.6 Handle classes ……………………………………………………………………….. 101
7.11.7 EJBMetaData class ………………………………………………………………… 101
7.11.8 Non-reentrant instances…………………………………………………………… 101
7.11.9 Transaction scoping, security, exceptions ………………………………….. 101
7.11.10 SessionContext………………………………………………………………………. 101
Chapter 8 Example Session Scenario ………………………………………………………………………………… 103
8.1 Overview …………………………………………………………………………………………… 103
8.2 Inheritance relationship ……………………………………………………………………….. 103
8.2.1 What the session Bean provider is responsible for ……………………… 105
8.2.2 Classes supplied by container provider……………………………………… 105
8.2.3 What the container provider is responsible for …………………………… 105
Chapter 9 Client View of an Entity……………………………………………………………………………………. 107
9.1 Overview …………………………………………………………………………………………… 107

Sun Microsystems, Inc.
9.2 Remote Clients……………………………………………………………………………………. 108
9.3 Local Clients………………………………………………………………………………………. 108
9.4 EJB Container…………………………………………………………………………………….. 109
9.4.1 Locating an entity bean’s home interface…………………………………… 110
9.4.2 What a container provides……………………………………………………….. 110
9.5 Entity bean’s remote home interface ……………………………………………………… 111
9.5.1 create methods……………………………………………………………………….. 112
9.5.2 finder methods ……………………………………………………………………….. 113
9.5.3 remove methods …………………………………………………………………….. 113
9.5.4 home methods ……………………………………………………………………….. 114
9.6 Entity bean’s local home interface…………………………………………………………. 114
9.6.1 create methods……………………………………………………………………….. 115
9.6.2 finder methods ……………………………………………………………………….. 116
9.6.3 remove methods …………………………………………………………………….. 116
9.6.4 home methods ……………………………………………………………………….. 117
9.7 Entity object’s life cycle ………………………………………………………………………. 117
9.7.1 References to entity object remote interfaces……………………………… 119
9.7.2 References to entity object local interfaces………………………………… 119
9.8 Primary key and object identity …………………………………………………………….. 120
9.9 Entity Bean’s remote interface………………………………………………………………. 121
9.10 Entity Bean’s local interface…………………………………………………………………. 122
9.11 Entity bean’s handle…………………………………………………………………………….. 123
9.12 Entity home handles ……………………………………………………………………………. 124
9.13 Type narrowing of object references………………………………………………………. 124
Chapter 10 Entity Bean Component Contract for Container-Managed Persistence……………………. 125
10.1 Overview……………………………………………………………………………………………. 126
10.2 Container-managed entity persistence and data independence…………………… 126
10.3 The entity bean provider’s view of container-managed persistence……………. 128
10.3.1 The entity bean provider’s programming contract ………………………. 129
10.3.2 The entity bean provider’s view of persistent relationships ………….. 131
10.3.3 Dependent value classes ………………………………………………………….. 131
10.3.4 Remove protocols…………………………………………………………………… 132
10.3.4.1 Remove methods……………………………………………………….. 132
10.3.4.2 Cascade-delete ………………………………………………………….. 133
10.3.5 Identity of entity objects………………………………………………………….. 133
10.3.6 Semantics of assignment for relationships …………………………………. 134
10.3.6.1 Use of the java.util.Collection API to update relationships 134
10.3.6.2 Use of set accessor methods to update relationships ………. 135
10.3.7 Assignment rules for relationships ……………………………………………. 137
10.3.7.1 One-to-one bidirectional relationships………………………….. 137
10.3.7.2 One-to-one unidirectional relationships………………………… 138
10.3.7.3 One-to-many bidirectional relationships……………………….. 139
10.3.7.4 One-to-many unidirectional relationships……………………… 143
10.3.7.5 Many-to-one unidirectional relationships ……………………… 146
10.3.7.6 Many-to-many bidirectional relationships …………………….. 148

Sun Microsystems, Inc.
10.3.7.7 Many-to-many unidirectional relationships…………………… 152
10.3.8 Collections managed by the Container ……………………………………… 155
10.3.9 Non-persistent state………………………………………………………………… 155
10.3.10 The relationship between the internal view and the client view ……. 156
10.3.10.1 Restrictions on remote interfaces…………………………………. 156
10.3.11 Mapping data to a persistent store…………………………………………….. 156
10.3.12 Example ……………………………………………………………………………….. 157
10.3.13 The Bean Provider’s view of the deployment descriptor ……………… 160
10.4 The entity bean component contract………………………………………………………. 164
10.4.1 Runtime execution model of entity beans ………………………………….. 164
10.4.2 Container responsibilities………………………………………………………… 166
10.4.2.1 Container-managed fields …………………………………………… 166
10.4.2.2 Container-managed relationships ………………………………… 166
10.5 Instance life cycle contract between the bean and the container………………… 167
10.5.1 Instance life cycle…………………………………………………………………… 168
10.5.2 Bean Provider’s entity bean instance’s view………………………………. 170
10.5.3 Container’s view…………………………………………………………………….. 174
10.5.4 The EntityContext interface……………………………………………………… 178
10.5.5 Operations allowed in the methods of the entity bean class …………. 179
10.5.6 Finder methods………………………………………………………………………. 181
10.5.6.1 Single-object finder……………………………………………………. 181
10.5.6.2 Multi-object finders …………………………………………………… 182
10.5.7 Select methods ………………………………………………………………………. 182
10.5.7.1 Single-object select methods ………………………………………. 183
10.5.7.2 Multi-object select methods………………………………………… 183
10.5.8 Standard application exceptions for Entities………………………………. 184
10.5.8.1 CreateException………………………………………………………… 184
10.5.8.2 DuplicateKeyException ……………………………………………… 185
10.5.8.3 FinderException………………………………………………………… 185
10.5.8.4 ObjectNotFoundException …………………………………………. 185
10.5.8.5 RemoveException……………………………………………………… 186
10.5.9 Commit options……………………………………………………………………… 186
10.5.10 Concurrent access from multiple transactions ……………………………. 187
10.5.11 Non-reentrant and re-entrant instances ……………………………………… 189
10.6 Responsibilities of the Enterprise Bean Provider …………………………………….. 190
10.6.1 Classes and interfaces …………………………………………………………….. 190
10.6.2 Enterprise bean class ………………………………………………………………. 190
10.6.3 Dependent value classes………………………………………………………….. 191
10.6.4 ejbCreate<METHOD> methods ………………………………………………. 191
10.6.5 ejbPostCreate<METHOD> methods ………………………………………… 192
10.6.6 ejbHome<METHOD> methods……………………………………………….. 193
10.6.7 ejbSelect<METHOD> methods……………………………………………….. 193
10.6.8 Business methods…………………………………………………………………… 193
10.6.9 Entity bean’s remote interface………………………………………………….. 194
10.6.10 Entity bean’s remote home interface…………………………………………. 194
10.6.11 Entity bean’s local interface …………………………………………………….. 195
10.6.12 Entity bean’s local home interface ……………………………………………. 196
10.6.13 Entity bean’s primary key class………………………………………………… 197
10.6.14 Entity bean’s deployment descriptor…………………………………………. 197
Sun Microsystems, Inc.
10.7 The responsibilities of the Container Provider ………………………………………… 197
10.7.1 Generation of implementation classes……………………………………….. 198
10.7.2 Enterprise bean class ………………………………………………………………. 198
10.7.3 ejbFind<METHOD> methods………………………………………………….. 199
10.7.4 ejbSelect<METHOD> methods ……………………………………………….. 199
10.7.5 Entity EJBHome class…………………………………………………………….. 200
10.7.6 Entity EJBObject class ……………………………………………………………. 200
10.7.7 Entity EJBLocalHome class…………………………………………………….. 201
10.7.8 Entity EJBLocalObject class……………………………………………………. 201
10.7.9 Handle class…………………………………………………………………………… 201
10.7.10 Home Handle class…………………………………………………………………. 202
10.7.11 Meta-data class………………………………………………………………………. 202
10.7.12 Instance’s re-entrance ……………………………………………………………… 202
10.7.13 Transaction scoping, security, exceptions ………………………………….. 202
10.7.14 Implementation of object references …………………………………………. 202
10.7.15 EntityContext…………………………………………………………………………. 203
10.8 Primary Keys ……………………………………………………………………………………… 203
10.8.1 Primary key that maps to a single field in the entity bean class …….. 203
10.8.2 Primary key that maps to multiple fields in the entity bean class ….. 203
10.8.3 Special case: Unknown primary key class …………………………………. 204
10.9 Object interaction diagrams………………………………………………………………….. 204
10.9.1 Notes…………………………………………………………………………………….. 204
10.9.2 Creating an entity object …………………………………………………………. 206
10.9.3 Passivating and activating an instance in a transaction ………………… 208
10.9.4 Committing a transaction ………………………………………………………… 210
10.9.5 Starting the next transaction …………………………………………………….. 211
10.9.6 Removing an entity object……………………………………………………….. 213
10.9.7 Finding an entity object…………………………………………………………… 214
10.9.8 Adding and removing an instance from the pool ………………………… 214
Chapter 11 EJB QL: EJB Query Language for Container-Managed Persistence Query Methods… 217
11.1 Overview……………………………………………………………………………………………. 217
11.2 EJB QL Definition ………………………………………………………………………………. 218
11.2.1 Abstract schema types and query domains ………………………………… 219
11.2.2 Query methods ………………………………………………………………………. 220
11.2.3 Naming…………………………………………………………………………………. 220
11.2.4 Examples ………………………………………………………………………………. 220
11.2.5 Return Value Types ………………………………………………………………… 222
11.2.6 The FROM clause and navigational declarations………………………… 223
11.2.6.1 Identifiers …………………………………………………………………. 223
11.2.6.2 Identification variables……………………………………………….. 223
11.2.6.3 Range variable declarations ………………………………………… 224
11.2.6.4 Collection member declarations ………………………………….. 225
11.2.6.5 Example …………………………………………………………………… 225
11.2.6.6 Path expressions………………………………………………………… 225
11.2.7 WHERE clause and conditional cxpressions ……………………………… 226
11.2.7.1 Literals …………………………………………………………………….. 227
11.2.7.2 Identification variables……………………………………………….. 227

Sun Microsystems, Inc.
11.2.7.3 Path expressions………………………………………………………… 227
11.2.7.4 Input parameters ……………………………………………………….. 228
11.2.7.5 Conditional expression composition…………………………….. 228
11.2.7.6 Operators and operator precedence ……………………………… 229
11.2.7.7 Between expressions………………………………………………….. 229
11.2.7.8 In expressions …………………………………………………………… 229
11.2.7.9 Like expressions………………………………………………………… 230
11.2.7.10 Null comparison expressions………………………………………. 230
11.2.7.11 Empty collection comparison expressions…………………….. 231
11.2.7.12 Collection member expressions…………………………………… 231
11.2.7.13 Functional expressions……………………………………………….. 231
11.2.8 SELECT clause ……………………………………………………………………… 232
11.2.9 Null values ……………………………………………………………………………. 233
11.2.10 Equality semantics …………………………………………………………………. 235
11.2.11 Restrictions……………………………………………………………………………. 235
11.3 Examples …………………………………………………………………………………………… 235
11.3.1 Simple queries……………………………………………………………………….. 236
11.3.2 Queries with relationships……………………………………………………….. 236
11.3.3 Queries using input parameters………………………………………………… 237
11.3.4 Queries for select methods ………………………………………………………. 237
11.3.5 EJB QL and SQL …………………………………………………………………… 238
11.4 EJB QL BNF ……………………………………………………………………………………… 239
Chapter 12 Entity Bean Component Contract for Bean-Managed Persistence ………………………….. 243
12.1 Overview of Bean-Managed Entity Persistence ………………………………………. 243
12.1.1 Entity Bean Provider’s view of persistence………………………………… 244
12.1.2 Runtime execution model ……………………………………………………….. 245
12.1.3 Instance life cycle…………………………………………………………………… 247
12.1.4 The entity bean component contract …………………………………………. 249
12.1.4.1 Entity bean instance’s view…………………………………………. 249
12.1.4.2 Container’s view: ………………………………………………………. 252
12.1.5 Operations allowed in the methods of the entity bean class …………. 255
12.1.6 Caching of entity state and the ejbLoad and ejbStore methods …….. 258
12.1.6.1 ejbLoad and ejbStore with the NotSupported transaction attribute
259
12.1.7 Finder method return type……………………………………………………….. 260
12.1.7.1 Single-object finder……………………………………………………. 260
12.1.7.2 Multi-object finders …………………………………………………… 261
12.1.8 Standard application exceptions for Entities………………………………. 262
12.1.8.1 CreateException………………………………………………………… 263
12.1.8.2 DuplicateKeyException ……………………………………………… 263
12.1.8.3 FinderException………………………………………………………… 263
12.1.8.4 ObjectNotFoundException …………………………………………. 264
12.1.8.5 RemoveException……………………………………………………… 264
12.1.9 Commit options……………………………………………………………………… 264
12.1.10 Concurrent access from multiple transactions ……………………………. 265
12.1.11 Non-reentrant and re-entrant instances ……………………………………… 267
12.2 Responsibilities of the Enterprise Bean Provider …………………………………….. 268

12.2.1 Classes and interfaces……………………………………………………………… 268
12.2.2 Enterprise bean class ………………………………………………………………. 268
12.2.3 ejbCreate<METHOD> methods ………………………………………………. 269
12.2.4 ejbPostCreate<METHOD> methods…………………………………………. 270
12.2.5 ejbFind methods …………………………………………………………………….. 270
12.2.6 ejbHome<METHOD> methods ……………………………………………….. 271
12.2.7 Business methods …………………………………………………………………… 271
12.2.8 Entity bean’s remote interface………………………………………………….. 272
12.2.9 Entity bean’s remote home interface …………………………………………. 272
12.2.10 Entity bean’s local interface …………………………………………………….. 274
12.2.11 Entity bean’s local home interface ……………………………………………. 274
12.2.12 Entity bean’s primary key class………………………………………………… 275
12.3 The responsibilities of the Container Provider ………………………………………… 276
12.3.1 Generation of implementation classes……………………………………….. 276
12.3.2 Entity EJBHome class…………………………………………………………….. 276
12.3.3 Entity EJBObject class ……………………………………………………………. 277
12.3.4 Entity EJBLocalHome class…………………………………………………….. 277
12.3.5 Entity EJBLocalObject class……………………………………………………. 278
12.3.6 Handle class…………………………………………………………………………… 278
12.3.7 Home Handle class…………………………………………………………………. 278
12.3.8 Meta-data class………………………………………………………………………. 279
12.3.9 Instance’s re-entrance ……………………………………………………………… 279
12.3.10 Transaction scoping, security, exceptions ………………………………….. 279
12.3.11 Implementation of object references …………………………………………. 279
12.3.12 EntityContext…………………………………………………………………………. 279
12.4 Object interaction diagrams………………………………………………………………….. 279
12.4.1 Notes…………………………………………………………………………………….. 280
12.4.2 Creating an entity object …………………………………………………………. 281
12.4.3 Passivating and activating an instance in a transaction ………………… 282
12.4.4 Committing a transaction ………………………………………………………… 283
12.4.5 Starting the next transaction …………………………………………………….. 283
12.4.6 Removing an entity object……………………………………………………….. 285
12.4.7 Finding an entity object…………………………………………………………… 286
12.4.8 Adding and removing an instance from the pool ………………………… 286
Chapter 13 Example bean-managed persistence entity scenario ……………………………………………… 289
13.1 Overview……………………………………………………………………………………………. 289
13.2 Inheritance relationship ……………………………………………………………………….. 290
13.2.1 What the entity Bean Provider is responsible for………………………… 291
13.2.2 Classes supplied by Container Provider…………………………………….. 291
13.2.3 What the container provider is responsible for …………………………… 291
Chapter 14 EJB 1.1 Entity Bean Component Contract for Container-Managed Persistence ……….. 293
14.1 EJB 1.1 Entity beans with container-managed persistence ……………………….. 293
14.1.1 Container-managed fields………………………………………………………… 294
14.1.2 ejbCreate, ejbPostCreate …………………………………………………………. 295
14.1.3 ejbRemove…………………………………………………………………………….. 296

Sun Microsystems, Inc.
14.1.4 ejbLoad…………………………………………………………………………………. 297
14.1.5 ejbStore ………………………………………………………………………………… 297
14.1.6 finder methods……………………………………………………………………….. 297
14.1.7 home methods ……………………………………………………………………….. 298
14.1.8 create methods……………………………………………………………………….. 298
14.1.9 primary key type ……………………………………………………………………. 298
14.1.9.1 Primary key that maps to a single field in the entity bean class298
14.1.9.2 Primary key that maps to multiple fields in the entity bean class298
14.1.9.3 Special case: Unknown primary key class…………………….. 299
14.2 Object interaction diagrams………………………………………………………………….. 299
14.2.1 Notes ……………………………………………………………………………………. 299
14.2.2 Creating an entity object …………………………………………………………. 300
14.2.3 Passivating and activating an instance in a transaction ………………… 302
14.2.4 Committing a transaction ………………………………………………………… 304
14.2.5 Starting the next transaction…………………………………………………….. 305
14.2.6 Removing an entity object ………………………………………………………. 307
14.2.7 Finding an entity object…………………………………………………………… 308
14.2.8 Adding and removing an instance from the pool ………………………… 308
Chapter 15 Message-driven Bean Component Contract ………………………………………………………… 311
15.1 Overview …………………………………………………………………………………………… 311
15.2 Goals…………………………………………………………………………………………………. 312
15.3 Client view of a message-driven bean ……………………………………………………. 312
15.4 Protocol between a message-driven bean instance and its container ………….. 314
15.4.1 The required MessageDrivenBean interface ………………………………. 314
15.4.2 The required javax.jms.MessageListener interface ……………………… 315
15.4.3 The MessageDrivenContext interface ……………………………………….. 315
15.4.4 Message-driven bean’s ejbCreate() method ……………………………….. 316
15.4.5 Serializing message-driven bean methods …………………………………. 316
15.4.6 Concurrency of message processing …………………………………………. 316
15.4.7 Transaction context of message-driven bean methods…………………. 316
15.4.8 Message acknowledgment ………………………………………………………. 317
15.4.9 Association of a message-driven bean with a destination…………….. 317
15.4.9.1 Replying to a message ……………………………………………….. 318
15.4.10 Dealing with exceptions………………………………………………………….. 318
15.4.11 Missed ejbRemove() calls ……………………………………………………….. 318
15.5 Message-driven bean state diagram……………………………………………………….. 319
15.5.1 Operations allowed in the methods of a message-driven bean class. 320
15.6 Object interaction diagrams for a MESSAGE-DRIVEN bean…………………… 321
15.6.1 Message receipt: onMessage method invocation ………………………… 321
15.6.2 Adding instance to the pool …………………………………………………….. 322
15.6.3 Removing instance from the pool …………………………………………….. 322
15.7 The responsibilities of the bean provider ……………………………………………….. 323
15.7.1 Classes and interfaces …………………………………………………………….. 323
15.7.2 Message-driven bean class ………………………………………………………. 323
15.7.3 ejbCreate method …………………………………………………………………… 324
15.7.4 onMessage method…………………………………………………………………. 324

Sun Microsystems, Inc.
15.7.5 ejbRemove method…………………………………………………………………. 325
15.8 The responsibilities of the container provider …………………………………………. 325
15.8.1 Generation of implementation classes……………………………………….. 325
15.8.2 Deployment of message-driven beans……………………………………….. 325
15.8.3 Non-reentrant instances…………………………………………………………… 326
15.8.4 Transaction scoping, security, exceptions ………………………………….. 326
Chapter 16 Example Message-driven Bean Scenario…………………………………………………………….. 327
16.1 Overview……………………………………………………………………………………………. 327
16.2 Inheritance relationship ……………………………………………………………………….. 327
16.2.1 What the message-driven Bean provider is responsible for ………….. 329
16.2.2 Classes supplied by container provider ……………………………………… 329
16.2.3 What the container provider is responsible for …………………………… 329
Chapter 17 Support for Transactions …………………………………………………………………………………… 331
17.1 Overview……………………………………………………………………………………………. 331
17.1.1 Transactions…………………………………………………………………………… 331
17.1.2 Transaction model ………………………………………………………………….. 332
17.1.3 Relationship to JTA and JTS ……………………………………………………. 333
17.2 Sample scenarios ………………………………………………………………………………… 333
17.2.1 Update of multiple databases …………………………………………………… 333
17.2.2 Messages sent or received over JMS sessions and update of multiple databases334
17.2.3 Update of databases via multiple EJB Servers……………………………. 336
17.2.4 Client-managed demarcation……………………………………………………. 337
17.2.5 Container-managed demarcation………………………………………………. 338
17.3 Bean Provider’s responsibilities ……………………………………………………………. 339
17.3.1 Bean-managed versus container-managed transaction demarcation. 339
17.3.1.1 Non-transactional execution ……………………………………….. 339
17.3.2 Isolation levels……………………………………………………………………….. 339
17.3.3 Enterprise beans using bean-managed transaction demarcation ……. 340
17.3.3.1 getRollbackOnly() and setRollbackOnly() method ………… 347
17.3.4 Enterprise beans using container-managed transaction demarcation 348
17.3.4.1 javax.ejb.SessionSynchronization interface…………………… 349
17.3.4.2 javax.ejb.EJBContext.setRollbackOnly() method ………….. 349
17.3.4.3 javax.ejb.EJBContext.getRollbackOnly() method ………….. 350
17.3.5 Use of JMS APIs in transactions………………………………………………. 350
17.3.6 Declaration in deployment descriptor ……………………………………….. 350
17.4 Application Assembler’s responsibilities ……………………………………………….. 350
17.4.1 Transaction attributes ……………………………………………………………… 351
17.5 Deployer’s responsibilities……………………………………………………………………. 354
17.6 Container Provider responsibilities………………………………………………………… 355
17.6.1 Bean-managed transaction demarcation…………………………………….. 355
17.6.2 Container-managed transaction demarcation for Session and Entity Beans
357
17.6.2.1 NotSupported ……………………………………………………………. 357
17.6.2.2 Required…………………………………………………………………… 358

Sun Microsystems, Inc.
17.6.2.3 Supports …………………………………………………………………… 358
17.6.2.4 RequiresNew…………………………………………………………….. 358
17.6.2.5 Mandatory………………………………………………………………… 359
17.6.2.6 Never……………………………………………………………………….. 359
17.6.2.7 Transaction attribute summary ……………………………………. 360
17.6.2.8 Handling of setRollbackOnly() method………………………… 360
17.6.2.9 Handling of getRollbackOnly() method ……………………….. 361
17.6.2.10 Handling of getUserTransaction() method ……………………. 361
17.6.2.11 javax.ejb.SessionSynchronization callbacks………………….. 361
17.6.3 Container-managed transaction demarcation for Message-driven Beans362
17.6.3.1 NotSupported……………………………………………………………. 362
17.6.3.2 Required…………………………………………………………………… 362
17.6.3.3 Handling of setRollbackOnly() method………………………… 362
17.6.3.4 Handling of getRollbackOnly() method ……………………….. 363
17.6.3.5 Handling of getUserTransaction() method ……………………. 363
17.6.4 Local transaction optimization…………………………………………………. 363
17.6.5 Handling of methods that run with “an unspecified transaction context”363
17.7 Access from multiple clients in the same transaction context……………………. 364
17.7.1 Transaction “diamond” scenario with an entity object ………………… 365
17.7.2 Container Provider’s responsibilities ………………………………………… 366
17.7.3 Bean Provider’s responsibilities ……………………………………………….. 367
17.7.4 Application Assembler and Deployer’s responsibilities ………………. 368
17.7.5 Transaction diamonds involving session objects ………………………… 368
Chapter 18 Exception handling ………………………………………………………………………………………….. 371
18.1 Overview and Concepts……………………………………………………………………….. 371
18.1.1 Application exceptions……………………………………………………………. 371
18.1.2 Goals for exception handling …………………………………………………… 372
18.2 Bean Provider’s responsibilities ……………………………………………………………. 372
18.2.1 Application exceptions……………………………………………………………. 372
18.2.2 System exceptions………………………………………………………………….. 373
18.2.2.1 javax.ejb.NoSuchEntityException ……………………………….. 374
18.3 Container Provider responsibilities ……………………………………………………….. 374
18.3.1 Exceptions from a session or entity bean’s business methods ………. 375
18.3.2 Exceptions from message-driven bean methods …………………………. 377
18.3.3 Exceptions from container-invoked callbacks…………………………….. 378
18.3.4 javax.ejb.NoSuchEntityException…………………………………………….. 379
18.3.5 Non-existing session object……………………………………………………… 379
18.3.6 Exceptions from the management of container-managed transactions379
18.3.7 Release of resources……………………………………………………………….. 380
18.3.8 Support for deprecated use of java.rmi.RemoteException……………. 380
18.4 Client’s view of exceptions…………………………………………………………………… 381
18.4.1 Application exception …………………………………………………………….. 381
18.4.2 java.rmi.RemoteException and javax.ejb.EJBException ……………… 382
18.4.2.1 javax.transaction.TransactionRolledbackException and
javax.ejb.TransactionRolledbackLocalException383
18.4.2.2 javax.transaction.TransactionRequiredException and
javax.ejb.TransactionRequiredLocalException383

Sun Microsystems, Inc.
18.4.2.3 java.rmi.NoSuchObjectException and javax.ejb.NoSuchObjectLocalException383
18.5 System Administrator’s responsibilities …………………………………………………. 384
18.6 Differences from EJB 1.0 …………………………………………………………………….. 384
Chapter 19 Support for Distribution and Interoperability ………………………………………………………. 385
19.1 Support for distribution………………………………………………………………………… 385
19.1.1 Client-side objects in distributed environment……………………………. 386
19.2 Interoperability overview……………………………………………………………………… 386
19.2.1 Interoperability goals………………………………………………………………. 387
19.3 Interoperability Scenarios…………………………………………………………………….. 388
19.3.1 Interactions between web containers and EJB containers for e-commerce
applications388
19.3.2 Interactions between application client containers and EJB containers within
an enterprise’s intranet389
19.3.3 Interactions between two EJB containers in an enterprise’s intranet 390
19.3.4 Intranet application interactions between web containers and EJB containers
391
19.4 Overview of interoperability requirements……………………………………………… 391
19.5 Remote Invocation Interoperability ……………………………………………………….. 392
19.5.1 Mapping Java Remote Interfaces to IDL……………………………………. 393
19.5.2 Mapping value objects to IDL………………………………………………….. 393
19.5.3 Mapping of system exceptions …………………………………………………. 393
19.5.4 Obtaining stub and client view classes………………………………………. 394
19.5.5 System value classes ………………………………………………………………. 394
19.5.5.1 HandleDelegate SPI …………………………………………………… 395
19.6 Transaction interoperability ………………………………………………………………….. 396
19.6.1 Transaction interoperability requirements………………………………….. 396
19.6.1.1 Transaction context wire format ………………………………….. 396
19.6.1.2 Two-phase commit protocol………………………………………… 396
19.6.1.3 Transactional policies of enterprise bean references ………. 398
19.6.1.4 Exception handling behavior ………………………………………. 398
19.6.2 Interoperating with containers that do not implement transaction interoperability398
19.6.2.1 Client container requirements ……………………………………… 399
19.6.2.2 EJB container requirements ………………………………………… 399
19.7 Naming Interoperability……………………………………………………………………….. 401
19.8 Security Interoperability ………………………………………………………………………. 402
19.8.1 Introduction …………………………………………………………………………… 402
19.8.1.1 Trust relationships between containers, principal propagation403
19.8.1.2 Application Client Authentication ……………………………….. 404
19.8.2 Securing EJB invocations………………………………………………………… 404
19.8.2.1 Secure transport protocol ……………………………………………. 405
19.8.2.2 Security information in IORs………………………………………. 405
19.8.2.3 Propagating principals and authentication data in IIOP messages
406
19.8.2.4 Security configuration for containers……………………………. 408
19.8.2.5 Runtime behavior………………………………………………………. 408

Sun Microsystems, Inc.
Chapter 20 Enterprise bean environment …………………………………………………………………………….. 409
20.1 Overview …………………………………………………………………………………………… 409
20.2 Enterprise bean’s environment as a JNDI naming context ………………………… 410
20.2.1 Bean Provider’s responsibilities ……………………………………………….. 411
20.2.1.1 Access to enterprise bean’s environment………………………. 411
20.2.1.2 Declaration of environment entries………………………………. 412
20.2.2 Application Assembler’s responsibility …………………………………….. 414
20.2.3 Deployer’s responsibility ………………………………………………………… 415
20.2.4 Container Provider responsibility …………………………………………….. 415
20.3 EJB references ……………………………………………………………………………………. 415
20.3.1 Bean Provider’s responsibilities ……………………………………………….. 415
20.3.1.1 EJB reference programming interfaces ………………………… 416
20.3.1.2 Declaration of EJB references in deployment descriptor … 416
20.3.2 Application Assembler’s responsibilities…………………………………… 418
20.3.3 Deployer’s responsibility ………………………………………………………… 420
20.3.4 Container Provider’s responsibility…………………………………………… 420
20.4 Resource manager connection factory references ……………………………………. 421
20.4.1 Bean Provider’s responsibilities ……………………………………………….. 421
20.4.1.1 Programming interfaces for resource manager connection factory
references421
20.4.1.2 Declaration of resource manager connection factory references in
deployment descriptor422
20.4.1.3 Standard resource manager connection factory types …….. 425
20.4.2 Deployer’s responsibility ………………………………………………………… 425
20.4.3 Container provider responsibility……………………………………………… 426
20.4.4 System Administrator’s responsibility ………………………………………. 426
20.5 Resource environment references………………………………………………………….. 427
20.5.1 Bean Provider’s responsibilities ……………………………………………….. 427
20.5.1.1 Resource environment reference programming interfaces . 427
20.5.1.2 Declaration of resource environment references in deployment
descriptor428
20.5.2 Deployer’s responsibility ………………………………………………………… 428
20.5.3 Container Provider’s responsibility…………………………………………… 429
20.6 Deprecated EJBContext.getEnvironment() method …………………………………. 429
20.7 UserTransaction interface…………………………………………………………………….. 430
Chapter 21 Security management……………………………………………………………………………………….. 433
21.1 Overview …………………………………………………………………………………………… 433
21.2 Bean Provider’s responsibilities ……………………………………………………………. 435
21.2.1 Invocation of other enterprise beans …………………………………………. 435
21.2.2 Resource access……………………………………………………………………… 435
21.2.3 Access of underlying OS resources ………………………………………….. 435
21.2.4 Programming style recommendations……………………………………….. 435
21.2.5 Programmatic access to caller’s security context………………………… 436
21.2.5.1 Use of getCallerPrincipal() …………………………………………. 437
21.2.5.2 Use of isCallerInRole(String roleName) ………………………. 438
21.2.5.3 Declaration of security roles referenced from the bean’s code439
21.3 Application Assembler’s responsibilities ……………………………………………….. 440

Sun Microsystems, Inc.
21.3.1 Security roles…………………………………………………………………………. 441
21.3.2 Method permissions ……………………………………………………………….. 442
21.3.3 Linking security role references to security roles ……………………….. 446
21.3.4 Specification of security identities in the deployment descriptor…… 446
21.3.4.1 Run-as ……………………………………………………………………… 447
21.4 Deployer’s responsibilities……………………………………………………………………. 447
21.4.1 Security domain and principal realm assignment ……………………….. 448
21.4.2 Assignment of security roles ……………………………………………………. 448
21.4.3 Principal delegation………………………………………………………………… 449
21.4.4 Security management of resource access …………………………………… 449
21.4.5 General notes on deployment descriptor processing……………………. 449
21.5 EJB Client Responsibilities ………………………………………………………………….. 449
21.6 EJB Container Provider’s responsibilities ………………………………………………. 450
21.6.1 Deployment tools …………………………………………………………………… 450
21.6.2 Security domain(s) …………………………………………………………………. 450
21.6.3 Security mechanisms………………………………………………………………. 451
21.6.4 Passing principals on EJB calls ………………………………………………… 451
21.6.5 Security methods in javax.ejb.EJBContext ………………………………… 451
21.6.6 Secure access to resource managers………………………………………….. 452
21.6.7 Principal mapping ………………………………………………………………….. 452
21.6.8 System principal…………………………………………………………………….. 452
21.6.9 Runtime security enforcement …………………………………………………. 452
21.6.10 Audit trail ……………………………………………………………………………… 453
21.7 System Administrator’s responsibilities …………………………………………………. 453
21.7.1 Security domain administration ……………………………………………….. 453
21.7.2 Principal mapping ………………………………………………………………….. 454
21.7.3 Audit trail review……………………………………………………………………. 454
Chapter 22 Deployment descriptor ……………………………………………………………………………………… 455
22.1 Overview……………………………………………………………………………………………. 455
22.2 Bean Provider’s responsibilities ……………………………………………………………. 456
22.3 Application Assembler’s responsibility………………………………………………….. 458
22.4 Container Provider’s responsibilities ……………………………………………………… 460
22.5 Deployment descriptor DTD ………………………………………………………………… 460
Chapter 23 Ejb-jar file ………………………………………………………………………………………………………. 487
23.1 Overview……………………………………………………………………………………………. 487
23.2 Deployment descriptor…………………………………………………………………………. 488
23.3 Ejb-jar file requirements ………………………………………………………………………. 488
23.4 The client view and the ejb-client JAR file……………………………………………… 488
23.5 Requirements for clients ………………………………………………………………………. 489
23.6 Example …………………………………………………………………………………………….. 490
23.7 Removed in EJB 1.1 ……………………………………………………………………………. 490
23.7.1 ejb-jar Manifest ……………………………………………………………………… 490
23.7.2 Serialized deployment descriptor JavaBeans™ components ………… 491

Sun Microsystems, Inc.
Chapter 24 Runtime environment……………………………………………………………………………………….. 493
24.1 Bean Provider’s responsibilities ……………………………………………………………. 493
24.1.1 APIs provided by Container…………………………………………………….. 493
24.1.2 Programming restrictions ………………………………………………………… 494
24.2 Container Provider’s responsibility ……………………………………………………….. 496
24.2.1 Java 2 APIs requirements………………………………………………………… 497
24.2.2 EJB 2.0 requirements ……………………………………………………………… 498
24.2.3 JNDI 1.2 requirements ……………………………………………………………. 498
24.2.4 JTA 1.0.1 requirements …………………………………………………………… 499
24.2.5 JDBC™ 2.0 extension requirements…………………………………………. 499
24.2.6 JMS 1.0.2 requirements ………………………………………………………….. 499
24.2.7 Argument passing semantics……………………………………………………. 500
Chapter 25 Responsibilities of EJB Roles……………………………………………………………………………. 501
25.1 Bean Provider’s responsibilities ……………………………………………………………. 501
25.1.1 API requirements …………………………………………………………………… 501
25.1.2 Packaging requirements ………………………………………………………….. 501
25.2 Application Assembler’s responsibilities ……………………………………………….. 502
25.3 EJB Container Provider’s responsibilities ………………………………………………. 502
25.4 Deployer’s responsibilities …………………………………………………………………… 502
25.5 System Administrator’s responsibilities …………………………………………………. 502
25.6 Client Programmer’s responsibilities …………………………………………………….. 502
Chapter 26 Enterprise JavaBeans™ API Reference………………………………………………………………. 503
package javax.ejb………………………………………………………………………………… 504
package javax.ejb.spi …………………………………………………………………………… 504
package javax.ejb.deployment………………………………………………………………. 505
Chapter 27 Related documents…………………………………………………………………………………………… 507
Appendix A Features deferred to future releases ……………………………………………………………………. 509
Appendix B EJB 1.1 Deployment descriptor …………………………………………………………………………. 511
B.1 Overview …………………………………………………………………………………………… 511
B.2 Bean Provider’s responsibilities ……………………………………………………………. 512
B.3 Application Assembler’s responsibility………………………………………………….. 514
B.4 Container Provider’s responsibilities……………………………………………………… 515
B.5 Deployment descriptor DTD ………………………………………………………………… 515
B.6 Deployment descriptor example……………………………………………………………. 530
Appendix C EJB 1.1 Runtime environment …………………………………………………………………………… 537
C.1 EJB 1.1 Bean Provider’s responsibilities………………………………………………… 537

Sun Microsystems, Inc.
C.1.1 APIs provided by EJB 1.1 Container ………………………………………… 537
C.1.2 Programming restrictions ………………………………………………………… 538
C.2 EJB 1.1 Container Provider’s responsibility……………………………………………. 540
C.2.1 Java 2 Platform, Standard Edition, v 1.2 (J2SE) APIs requirements 541
C.2.2 EJB 1.1 requirements ……………………………………………………………… 542
C.2.3 JNDI 1.2 requirements ……………………………………………………………. 542
C.2.4 JTA 1.0.1 requirements……………………………………………………………. 542
C.2.5 JDBC™ 2.0 extension requirements …………………………………………. 542
C.2.6 Argument passing semantics ……………………………………………………. 542
Appendix D Frequently asked questions ……………………………………………………………………………….. 543
D.1 Client-demarcated transactions……………………………………………………………… 543
D.2 Container-managed persistence …………………………………………………………….. 544
D.3 Inheritance …………………………………………………………………………………………. 544
D.4 How to obtain database connections………………………………………………………. 544
D.5 Session beans and primary key……………………………………………………………… 545
D.6 Copying of parameters required for remote EJB calls within the same JVM . 545
Appendix E Revision History………………………………………………………………………………………………. 547
E.1 Version 0.1 …………………………………………………………………………………………. 547
E.2 Version 0.2 …………………………………………………………………………………………. 548
E.3 Version 0.3 …………………………………………………………………………………………. 548
E.4 Version 0.4 …………………………………………………………………………………………. 549
E.5 Version 0.5 …………………………………………………………………………………………. 549
E.6 Version 0.6 …………………………………………………………………………………………. 550
E.7 Version 0.7 …………………………………………………………………………………………. 550
E.8 Participant Draft………………………………………………………………………………….. 550
E.9 Public Draft………………………………………………………………………………………… 551
E.10 Public Draft 2……………………………………………………………………………………… 551
E.11 Proposed Final Draft……………………………………………………………………………. 552
E.12 Proposed Final Draft 2…………………………………………………………………………. 554
E.13 Final Draft………………………………………………………………………………………….. 556

Sun Microsystems, Inc.
List of Figures
Figure 1 Enterprise JavaBeans Contracts ………………………………………………………………………………………………..47
Figure 2 Client View of session beans deployed in a Container………………………………………………………………….58
Figure 3 Lifecycle of a session object. ……………………………………………………………………………………………………63
Figure 4 Session Bean Example Objects …………………………………………………………………………………………………64
Figure 5 Lifecycle of a STATEFUL Session bean instance………………………………………………………………………..77
Figure 6 OID for Creation of a session object …………………………………………………………………………………………83
Figure 7 OID for session object at start of a transaction. …………………………………………………………………………..84
Figure 8 OID for session object transaction synchronization……………………………………………………………………..85
Figure 9 OID for passivation and activation of a session object …………………………………………………………………86
Figure 10 OID for the removal of a session object …………………………………………………………………………………….87
Figure 11 Lifecycle of a STATELESS Session bean ………………………………………………………………………………….89
Figure 12 OID for creation of a STATELESS session object……………………………………………………………………….92
Figure 13 OID for invocation of business method on a STATELESS session object……………………………………….92
Figure 14 OID for removal of a STATELESS session object……………………………………………………………………….93
Figure 15 OID for Container Adding Instance of a STATELESS session bean to a method-ready pool…………….94
Figure 16 OID for a Container Removing an Instance of a STATELESS Session bean from ready pool …………..94
Figure 17 Example of Inheritance Relationships Between EJB Classes………………………………………………………104
Figure 18 Client view of entity beans deployed in a container …………………………………………………………………..111
Figure 19 Client View of Entity Object Life Cycle …………………………………………………………………………………..118
Figure 20 View of underlying data sources accessed through entity bean …………………………………………………..128
Figure 21 Relationship example …………………………………………………………………………………………………………….157
Figure 22 Overview of the entity bean runtime execution model………………………………………………………………..165
Figure 23 Life cycle of an entity bean instance. ……………………………………………………………………………………….168
Figure 24 Multiple clients can access the same entity object using multiple instances ………………………………….188
Figure 25 Multiple clients can access the same entity object using single instance……………………………………….189
Figure 26 OID of creation of an entity object with container-managed persistence ………………………………………207
Figure 27 OID of passivation and reactivation of an entity bean instance with container-managed persistence..209
Figure 28 OID of transaction commit protocol for an entity bean instance with container-managed persistence210
Figure 29 OID of start of transaction for an entity bean instance with container-managed persistence ……………212
Figure 30 OID of removal of an entity bean object with container-managed persistence……………………………….213
Figure 31 OID of execution of a finder method on an entity bean instance with container-managed persistence214
Figure 32 OID of a container adding an instance to the pool ……………………………………………………………………..215
Figure 33 OID of a container removing an instance from the pool……………………………………………………………..215
Figure 34 Several entity beans with abstract persistence schemas defined in the same ejb-jar file. …………………221
Figure 35 Client view of underlying data sources accessed through entity bean …………………………………………..244
Figure 36 Overview of the entity bean runtime execution model………………………………………………………………..246
Figure 37 Life cycle of an entity bean instance. ……………………………………………………………………………………….247
Figure 38 Multiple clients can access the same entity object using multiple instances ………………………………….266
Figure 39 Multiple clients can access the same entity object using single instance……………………………………….267

Sun Microsystems, Inc.
Figure 40 OID of Creation of an entity object with bean-managed persistence…………………………………………….281
Figure 41 OID of passivation and reactivation of an entity bean instance with bean-managed persistence ………282
Figure 42 OID of transaction commit protocol for an entity bean instance with bean-managed persistence …….283
Figure 43 OID of start of transaction for an entity bean instance with bean-managed persistence ………………….284
Figure 44 OID of removal of an entity bean object with bean-managed persistence ……………………………………..285
Figure 45 OID of execution of a finder method on an entity bean instance with bean-managed persistence …….286
Figure 46 OID of a container adding an instance to the pool ……………………………………………………………………..287
Figure 47 OID of a container removing an instance from the pool ……………………………………………………………..287
Figure 48 Example of the inheritance relationship between the remote interfaces and classes: ………………………290
Figure 49 OID of creation of an entity object with EJB 1.1 container-managed persistence…………………………..301
Figure 50 OID of passivation and reactivation of an entity bean instance with EJB 1.1 CMP ………………………..303
Figure 51 OID of transaction commit protocol for an entity bean instance with EJB 1.1 container-managed persistence304
Figure 52 OID of start of transaction for an entity bean instance with EJB 1.1 container-managed persistence..306
Figure 53 OID of removal of an entity bean object with EJB 1.1 container-managed persistence …………………..307
Figure 54 OID of execution of a finder method on an entity bean instance with EJB 1.1 container-managed persistence308
Figure 55 OID of a container adding an instance to the pool ……………………………………………………………………..309
Figure 56 OID of a container removing an instance from the pool ……………………………………………………………..309
Figure 57 Client view of message-driven beans deployed in a container……………………………………………………..313
Figure 58 Lifecycle of a MESSAGE-DRIVEN bean. ……………………………………………………………………………….319
Figure 59 OID for invocation of onMessage method on MESSAGE-DRIVEN bean instance………………………..321
Figure 60 OID for container adding instance of a MESSAGE-DRIVEN bean to a method-ready pool……………322
Figure 61 OID for a container removing an instance of MESSAGE-DRIVEN bean from ready pool……………..323
Figure 62 Example of Inheritance Relationships Between EJB Classes ………………………………………………………328
Figure 63 Updates to Simultaneous Databases…………………………………………………………………………………………334
Figure 64 Message sent to JMS queue and updates to multiple databases……………………………………………………335
Figure 65 Message sent to JMS queue serviced by message-driven bean and updates to multiple databases ……336
Figure 66 Updates to Multiple Databases in Same Transaction ………………………………………………………………….336
Figure 67 Updates on Multiple Databases on Multiple Servers ………………………………………………………………….337
Figure 68 Update of Multiple Databases from Non-Transactional Client…………………………………………………….338
Figure 69 Transaction diamond scenario with entity object ……………………………………………………………………….365
Figure 70 Handling of diamonds by a multi-process container ………………………………………………………………….367
Figure 71 Transaction diamond scenario with a session bean …………………………………………………………………….368
Figure 72 Location of EJB Client Stubs. …………………………………………………………………………………………………386
Figure 73 Heterogeneous EJB Environment ……………………………………………………………………………………………387
Figure 74 Transaction context propagation………………………………………………………………………………………………397

Sun Microsystems, Inc.
List of Tables
Table 1 EJB Roles in the example scenarios…………………………………………………………………………………………..39
Table 2 Operations allowed in the methods of a stateful session bean ……………………………………………………….80
Table 3 Operations allowed in the methods of a stateless session bean………………………………………………………90
Table 4 Operations allowed in the methods of an entity bean …………………………………………………………………179
Table 5 Comparison of finder and select methods …………………………………………………………………………………183
Table 6 Summary of commit-time options……………………………………………………………………………………………187
Table 7 Definition of the AND operator ………………………………………………………………………………………………234
Table 8 Definition of the OR operator………………………………………………………………………………………………….234
Table 9 Definition of the NOT operator ……………………………………………………………………………………………….234
Table 10 Operations allowed in the methods of an entity bean …………………………………………………………………257
Table 11 Summary of commit-time options……………………………………………………………………………………………265
Table 12 Operations allowed in the methods of a message-driven bean……………………………………………………..320
Table 13 Container’s actions for methods of beans with bean-managed transaction ……………………………………356
Table 14 Transaction attribute summary ………………………………………………………………………………………………..360
Table 15 Handling of exceptions thrown by a business method of a bean with container-managed transaction
demarcation375
Table 16 Handling of exceptions thrown by a business method of a session with bean-managed transaction
demarcation377
Table 17 Handling of exceptions thrown by a method of a message-driven bean with container-managed transaction
demarcation.377
Table 18 Handling of exceptions thrown by a method of a message-driven bean with bean-managed transaction
demarcation.378
Table 19 Java 2 Platform Security policy for a standard EJB Container …………………………………………………….498
Table 20 Java 2 Platform Security policy for a standard EJB Container …………………………………………………….541

原文出處:http://www.itcert.org/viewthread.php?tid=213

This entry was posted in SCBCD, SUN.

Comments are closed.

在线客服系统