The Contents of an Enterprise Bean ............................................................................................... 447
Packaging Enterprise Beans in EJB JAR Modules .................................................................. 447
Packaging Enterprise Beans in WAR Modules ...................................................................... 448
Naming Conventions for Enterprise Beans ................................................................................... 449
The Lifecycles of Enterprise Beans .................................................................................................. 450
The Lifecycle of a Stateful Session Bean .................................................................................. 450
The Lifecycle of a Stateless Session Bean ................................................................................. 451
The Lifecycle of a Singleton Session Bean ............................................................................... 451
The Lifecycle of a Message-Driven Bean ................................................................................. 452
Further Information about Enterprise Beans ................................................................................ 453
23 Getting Started with Enterprise Beans .......................................................................................... 455
Creating the Enterprise Bean ........................................................................................................... 455
Coding the Enterprise Bean Class ............................................................................................ 456
Creating the converter Web Client ........................................................................................ 456
Running the converter Example ............................................................................................ 457
Modifying the Java EE Application ................................................................................................. 458
▼ To Modify a Class File ................................................................................................................ 458
24 Running the Enterprise Bean Examples ........................................................................................ 461
The cart Example ............................................................................................................................. 461
The Business Interface ............................................................................................................... 462
Session Bean Class ..................................................................................................................... 463
The @Remove Method ................................................................................................................. 466
Helper Classes ............................................................................................................................. 466
Running the cart Example ....................................................................................................... 466
A Singleton Session Bean Example: counter ................................................................................. 468
Creating a Singleton Session Bean ........................................................................................... 468
The Architecture of the counter Example .............................................................................. 472
Running the counter Example ................................................................................................ 475
A Web Service Example: helloservice ......................................................................................... 476
The Web Service Endpoint Implementation Class ................................................................ 476
Stateless Session Bean Implementation Class ........................................................................ 477
Running the helloservice Example ...................................................................................... 477
Using the Timer Service .................................................................................................................... 479
Contents
The Java EE 6 Tutorial • January 201316