Index
A
abstract
class 154–155
methods 159–160, 220–222, 229
persistence schema 202, 213–214, 229–235
schema and query syntax 231
access methods 217
accessing an entity bean concurrently 145
ACID test for transactions 269
<acknowledge-mode> 250
administrator role 14
afterBegin() method 284–285
afterCompletion() method 284–285
application assembler
EJB 29, 42–43, 46–47
J2EE 13
questions 52, 362
application client 9
application deployer 13
application exceptions
class 86, 93, 116, 170–171
EJB 295–298
home interface 60
message driven bean 254
applications
J2EE 6–15
<assembly-descriptor> 282, 313
asynchronous communication 25, 27, 47, 248
atomicity 20, 153, 269
attributes 274–284
authentication 11, 20, 311
authorization 11, 44, 311–312, 314–315
AUTO-ACKNOWLEDGE 250
B
bean construction 166
bean deployer 28, 32, 130
bean managed persistence
comparison with CMP 154–156
definition 128
find methods 134, 297
questions on 178, 378
bean managed transaction demarcation (BMT)
container managed and 268, 305
EJB transactions 270–274
EJBContext methods 94, 164–165, 279
entity beans 194
message-driven beans 249–251, 257
questions 264, 286–290, 308, 393, 395, 398
session beans 98, 113–114, 117, 284
bean provider
bean class 175
client 21, 66
EJB security 318–326
ejb-jar file 46–47
entity beans 130–133, 139, 162–163, 181–182
EntityContext interface 166
external resources 39–41
interfaces 59, 61–62, 71, 142
methods 111, 151, 157, 169, 186–188
programming restrictions 37
questions 50–52, 78, 102, 148, 361–364
session beans 80–82, 84–87, 105–106
virtual persistent fields 159–160
bean-managed transactions demarcation 272
beforeCompletion() method 284–285
begin() method in the UserTransaction interface 273–274
BETWEEN 238
BMP entity bean 154
business logic
EJB architecture 21–25, 27–28, 30–33
influence on EJB security 323–324
J2EE architecture 4–5, 7–10
business methods
calling transaction related methods 279–281
EJB security in 312–313, 320–321
entity beans 155–161, 184–190, 192–194, 196–197
home business methods 137–138
MDB class 251–252
programming for CMP and CMR 217–218
questions on 146–148, 368–369, 371–374, 392–393
session beans 63–67, 72–74, 85–86, 116–118
business tier
EJB architecture 17, 21, 23, 47
EJB container 7
EJB tier in J2EE 4–5, 15
services 9–10
C
callback methods
bean's lifecycle 99
entity bean 154–155, 157
message driven bean 259
prefix ejb 67, 116, 193
session bean 87
transaction related 284
callbacks
ejbActivate() in entity bean 186
cascade delete 215–216, 221, 226, 387
cast 49
characteristics of an entity bean 131
checked exceptions 294
client tier 5, 9–10, 15
client view
definition 57–58
entity beans 125–150
exceptions 303
local interface 70
locating home interface 73
message driven beans 247–248, 250–251, 257
remote interface 65
session beans 82
CMP
definition 128
entity beans 154–156, 159–160, 222–223
programming 217–220
questions 177–179
CMP fields
CMR fields 219–220
definition 203
EJB-QL 228–233
get and set methods 211–212, 216–217
questions 243, 386, 390
<cmp-field> 213
CMR 69, 384–386
CMR fields
access methods 220
definition 203, 211
EJB-QL 228–229, 233
methods 216–217
questions 224, 384
<cmr-field> 215
<cmr-field-name> 215
coding the bean class 32
coding the bean interfaces 33
Collection of instances 209
collections in path navigation 234
communicating with the container 189
component interface
entity bean 133–135
example 33–34
questions 78–80, 148–150, 364–366
relationships 222–224
session bean 64–72
component-based architecture 15
concurrent access to a session bean 75
consistency 269
container callbacks methods
bean provider 160
definition 86, 89
EntityBean 157
SessionBean 118
See also callbacks
container managed transaction demarcation
EJB transactions 270–274, 284–290
EJBContext/SessionContext methods 94
EntityContext methods 165
MDB 249–250, 256–257
questions 398–399
container requirements 16, 20
container-managed persistence 154
Container-managed persistent fields 212
container-managed relationship fields 214
container-managed relationships 207
container-managed transaction demarcation 274
<container-transaction> 283
conversational state 58, 81–83, 109
create() method
entity beans 135–136
example 34
MDB 253
questions 78–80, 120–121, 148–149
session beans 60–63, 82, 85, 92–93
session beans and entity beans 135
CreateException
create() method 60, 63
explained 296
local and remote interfaces 72–73
creating an entity bean 168
creation of a stateless session bean 83
CustomerBean 127, 143, 212–216
D
database API 10
database API technologies 10
database to entity mapping 128, 229
declarative security, limitations of 319
defining transaction 268
deletingentity from database 195
deployer 13
EJB role of a 29
deployment descriptor 154
deployment descriptor files 187
<description> 313
<destination-type> 259
disabling methods 319
distributed application 8
distributed architecture 4, 6, 8, 12
distributed environment 4–5, 10–11, 14
distributed transaction manager 270
does not exist state 182
DOM 11
DuplicateKeyException 296, 309, 400
DUPS-OK-ACKNOWLEDGE 250
durable subscription 259
Duraility 269
E
EIS tier 9–10
EJB 2.0 14
EJB 2.0 spec 141
EJB 2.1 14
EJB 3.0 14
EJB components 17
EJB container provider 28, 30
EJB Home object 91
EJB Home stub 91
EJB Object 65, 68, 75, 79–80, 366
EJB QL queries 228
EJB query language 227
EJB references 40–41
EJB role of an 29
EJB roles 16, 31–32, 49
EJB security 310
EJB server provider 28, 30
EJB specifications 18, 29, 48
EJB system exceptions 298
EJB tier 5, 9, 15
EJB transactions 267
ejbActivate()
entity bean 185–186
implementing 111–112
programming 162–163
questions 120–121, 199–200
transaction context 277
usage 87
ejbCreate()
ejbCreate<method> 64, 84
ejbPostCreate() 197
entity bean 168–174
MDB 252–256
method definition 33
questions 102–104, 120–122, 199
session bean 88–93
transaction context 277
usage 87
EJBException 292
explained 298–301
for local client 73
getPrimaryKey() method 72
questions 307–309
ejbFind method 156, 184, 186
EJBHome 59–62, 64–65, 68–72, 76–78, 364
ejbHome method 184
ejb-jar file 13
ejb-jar.xml
descriptor 29, 36, 48
See also deployment
ejbLoad()
called by the container 163
missing from session bean 87, 158
NoSuchEntityException 300
permitted operations 191–192
questions 327, 382
EJBLocalHome 69–72, 77, 83, 99, 141–142, 148
EJBLocalObject 83, 95, 99, 141
EJBMetaData interface 61, 70, 133
EJBObject
definition 18–19
entity beans 137–142, 144–146, 187–192
questions 49–50, 77, 79–80
reference 97
session beans 65–72
used in programming 33–34
ejbPassivate()
entity beans 162–163, 185–186
method definition 33
permitted operations 192–193
questions 120–122, 382–383
session bean 87–89, 108–109, 111–117
transaction context 277
usage 87
ejbPostCreate() 161, 168–169, 197, 296
<ejb-relation> 215
<ejb-relationship-role> 215
<ejb-relationship-role-name> 215
ejbRemove()
MDB 252–256
method definition 33
questions 103, 120, 122, 262–264
transaction context 277
usage 87, 108–109, 252
ejbSelect method 184, 187
ejbStore()
missing from session bean 87
permitted operations 192–193
questions 381–382, 384, 403
usage 158
Enterprise JavaBeans 3
entities in the database 131
entity and entity bean 129
Entity bean and entity bean instance 130
entity bean class 129
entity bean instance 129–130, 184, 195
entity bean lifecycle 182
entity bean persistence 152
entity bean remote home interface 131
entity beans 125, 151, 181
activation 191
client view 125
definition 19, 26
interfaces 164
lifecycle 181
passivation 192
entity beans and database tables 203
Entity, entity bean, and entity bean instance 129
EntityBean interface 152
EntityContext 183, 189
environment entries 40, 49
exception handling 293
exceptions in EJB 295, 305
checked exceptions 294
exceptions tree in Java 293
<exclude-list> 319
F
findByPrimaryKey() 134
finder methods 134–135
FinderException 297
FROM clause 242, 388
functionality of an entity bean 127
G
getByPrimaryKey(?) 134
getCallerPrincipal() 95, 320
getEJBHome() 67
getEJBLocalHome() 256–257, 280
getEJBLocalObject() 37, 95, 165
getEJBMetaData() 61, 70, 133, 141
getEJBObject() 93
getHandle() 67
getHomeHandle() 61, 133
getPrimaryKey() 67
getRollbackOnly() 256–257, 271–272, 279, 286
getStatus() 272, 286, 290–291, 395–396
getUserTransaction() 164–165, 194, 271–273, 279
guaranteed services and APIs 45
H
Handle 67, 69–70, 140, 280
home business methods 190
home interface
create and remove methods 62
local, 70
locating the 73
writing a 60
home object 35
HTML 9, 13
I
identifiers and input parameters 235
identifying entity beans 172
IIOP compatible types 63, 69, 76–77, 224, 384
IllegalStateException 97, 100, 279, 304–305
implementing a session bean 84
IN expression in EJB QL 239
InitialContext() 35, 39, 42, 73, 88, 143, 250, 302
interface
EJBLocalHome 69–71, 77, 141–142
EJBLocalObject 69–71, 77, 141–142
EJBObject 67
EntityBean 157
EntityContext 164
MessageDrivenBean 248, 252–253
MessageDrivenContext 256
SessionBean 86
interoperability 6
introducing entity beans 126
introduction to session beans 82
IS EMPTY 238, 240
IS NOT EMPTY 238
isCallerInRole() 257, 320–321, 323
isIdentical() 68–69, 175, 208, 280
J
J2EE 1.3 8, 12, 14
J2EE 1.4 14
J2EE 1.5 14
J2EE and EJB versions 14
J2EE architecture 3–5, 7–8, 12, 17, 39
J2EE implementation 12
J2EE platform 3, 6–8, 10, 12, 14
J2EE reference implementation 14
J2EE server 7–8, 13–14
J2SE 8, 45–46, 49
JAAS 11–12
Java Message Service 45
Java Server Pages. See JSP
JavaBeans and Enterprise JavaBeans 23
JavaMail 12
JAXP (Java API for XML Parsing) 11–12, 45, 51, 361
JDBC API 12
JMS 11–12
JMS (Java Messaging Service) 19, 248
JMS consumer 248
JMS destination 250
JMS message consumer 249
JMS producer 248
JNDI (Java Naming and Directory Interface)
definition 10
EJB 39–45
entity bean 190–195
J2EE 10
JNDI context and session context 96, 166
lookup 73–74, 142–143, 250
questions 51, 53, 200–201
JNDI lookup 131
JSP 4, 9, 12–13, 29, 45
JTA (Java Transaction API) 10, 12, 20, 45
L
lifecycle management 20
LIKE expression in EJB QL 235, 238–240
local home interface 142
local interfaces 69–70, 141
exceptions in 72
writing 72
local transaction manager 270
locating the home interface 143
location transparency 21
lookup. See JNDI lookup
M
mail service 11
managing persistence and relationships 211
many-to-many relationships 210
message listener 250
message service 11
message-driven beans 247
definition 27
MessageDrivenBean interface 248, 251–254, 259, 261–262, 391
MessageDrivenContext interface 247–248, 252–253, 256–257, 261, 272–273
MessageListener interface 251–254, 259, 261–262, 391
<message-driven> 258
<message-driven-destination> 258–259
MessageListener 248, 252–253
method permissions 314
<method> 314
<method-intf> 317
<method-name> 230, 314
<method-param> 283
<method-params> 230, 283
<method-permission> 314
methods
afterBegin() 284–285
afterCompletion() 284–285
beforeCompletion 284–285
begin() 273–274
commit() 273–274
ejbSelect() 200, 382
getCallerPrincipal() 95, 98, 317, 320, 323
getEJBHome() 67, 95, 256–257, 280
getEJBLocalObject() 37, 95, 165
getEJBMetaData() 61, 70, 133, 141
getEJBObject() 37, 95, 165
getHandle() 67, 69, 140, 280
getHomeHandle() 61, 133
getPrimaryKey() 68, 72, 95, 164–166, 299
getStatus() 272, 286, 290–291, 395–396
remove() 59, 62, 68–69, 133, 136–137
rollback() 273, 290–291, 395–396
setMessageDrivenContext() 252, 254, 256, 259
setRollbackOnly() 95, 165, 256–257, 271–272, 285–288
setSessionContext() 33, 87–98, 107, 112, 158
setTransactionTimeout() 272, 290, 395–396
methods from the component interface 156
methods from the home interface 155
missed ejbRemove() calls 115
multiple-field key 173
multiplicity in relationships 203, 210, 215–216, 220–223, 226
Multitier architecture 5
N
naming service 10
navigating to the related bean 234
nested transactions 273, 288
Never attribute in transactions 159, 275–279, 281, 283
newInstance() 89–91, 100, 163, 183–184, 254–255
non-durable subscription 258
NoSuchEntityException 300, 305, 307, 309, 397–400
NoSuchObjectException 68, 115, 299–300, 305
NoSuchObjectLocalException 72, 115, 121, 299–300, 305
NOT BETWEEN 238
NOT IN expression in EJB QL 239
NotSupported attribute 275–281, 286, 288–291, 308
O
object serialization 111
ObjectNotFoundException
Explained 297
finder methods 134, 187
questions 121, 150, 373, 377
one-to-many relationships 208
one-to-one relationships 207
onMessage(?) method 249
operators and expressions 237
OrderBackupBean, 205
OrderBean 205
overlap of roles 31
overloaded methods 316
overview of the EJB architecture 18
P
Passivation
definition 109
entity bean 185–187, 191–192
session bean 111, 113
path navigation in EJB QL 233
performance 6
persistence management 20, 45
<persistence-type> 213
persistent data storage 58
persistent fields 152
persistent fields of an entity bean 203
persistent state 154
pool 58, 62–65, 87, 89–90
pooled state 182–184, 186, 196–199, 254–255
portability 6
PortableRemoteObject 35, 42, 74, 143, 302
primary key
entity beans 134, 136–137, 139–140, 165–168, 187–193
questions 199–201, 378
session beans 62, 64, 68, 95
<prim-key-class> 213
<primkey-field> 213
principals and roles 311
programmatic security 311, 318, 320, 323–324
programming restrictions 37
programming security 319
propagating security identity 317
publish/subscribe messaging model 258
Q
Queries 231
query domain 235
query domains and navigation 233
query return types 232
<query> 229
<query-method> 229
Queues in messaging 258
R
ready state 185
reestablishing relationships 210
references to security roles 321
relational database 14, 129
relationship between two entity beans 206
<relationship-role-source> 215
relationships, one to one 207, 210
reliability 25
remote access service 11
remote client 57–59, 65, 69–70, 72–77, 79
remote component interface 65, 138
RemoteException
EJB 295–296, 298–301
entity beans 136–138, 170–171, 194
example 34, 60
interfaces 63–67
questions 102, 104, 121, 307–309
session bean 71–73, 76–79, 116
remove methods 136
remove protocols 221
RemoveException 62, 64–65, 73, 136–137, 297
removing a bean instance 195
removing a session bean instance 114
Required attribute in transactions 275, 277–281, 394–396
RequiresNew attribute in transactions 274–279, 281, 283–284, 288–291, 394–396
re-usability 23
role of EJB QL in persistence 228
<role-link> 322
rollback() 273, 290–291, 396
<run-as> 318
RuntimeException 294–296, 298–299, 303–304, 307, 397
S
SAX (Simple API for XML) 11
scalability 5–6
security 31, 47, 310, 324
bean developers role in 320
concepts 311
declarative 318–320, 323–324
information about the client 191
management 20, 45, 51, 360
programmatic 311, 318, 320, 323–324
roles 313
<security-identity> 213, 317
<security-role> 313
<security-role-ref> 321
SELECT clause in EJB QL 186, 227, 230–236, 238–242, 388
select methods 231
select queries 187
session bean
definition 19, 26, 47, 58, 82
remote home interface 59
SessionBean 32–33, 81–84, 86–90, 158, 184
SessionContext 33, 88–91, 93–97, 107, 111–113
SessionSynchronization 89, 267, 281, 284–286
setEntityContext()
definition 87, 161
questions 178, 378, 382, 403
unsetEntityContext() 184
setSessionContext()
in creation process 90–91
method definition 33
permitted operations 97
questions 120–122
SessionContext 93–94
usage 87
single-field key 173
software components 18, 21, 40, 47
stateful life cycle 106
stateful session bean 26, 49, 58, 62–64, 68
does not exist state 106
stateless session bean 58, 60–65, 68, 76–80
<subscription-durability> 259
Supports attribute in EJB QL 275–279, 281, 289–291, 394–396
synchronizing entity and entity bean 153
synchronous communication 25–27, 47
system exceptions 304
T
to 191, 193
Topic destination 258
transaction attributes
Mandatory 135, 275, 277–278, 281, 283
Never 159, 275–279, 281, 283
NotSupported 275–281, 286, 288–291
Required 275–281, 286, 288–291
RequiresNew 275, 277–281, 286, 288–291
Supports 275–279, 281, 289–291, 394–396
transaction definition 268
transaction demarcation 270
transaction management 20, 51, 360
transaction rollback 191, 269
transaction service 10
TransactionRequiredException 300, 307, 397
TransactionRequiredLocalException 300
TransactionRolledbackException 300, 308, 399
TransactionRolledbackLocalException 300
transactions
ACID test 269
bean managed versus container managed transaction 164
distributed 270