The CartEJB Example

The CartEJB session bean represents a shopping cart in an online bookstore. The bean’s client may add a book to the cart, remove a book, or retrieve the cart’s contents. To construct CartEJB, you need the following code:

  • Session bean class (CartBean)

  • Home interface (CartHome)

  • Remote interface (Cart)

All session beans require a session bean class. All enterprise beans that permit remote access must have a home and remote interface. To meet the needs of a specific application, an enterprise bean may also need some helper classes. The CartEJB session bean uses two helper classes, BookException and IdVerifier, which are discussed in the section Helper Classes (page 76).

The source code for this example is in the j2eetutorial/examples/src/ejb/cart ...

Get J2EE™ Tutorial, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.