The Session Bean Code
The session bean declared for the shopping cart EJB demonstrates object-oriented code reuse by simply extending the ShoppingCartBean class developed for the first example. Since the EJB specification allows EJBs to be part of an inheritance hierarchy (even though they themselves cannot be extended), this use of inheritance is allowed.
The ejbCreate method shown next has been overloaded to accept an argument for the userID. This integer value is passed to the method and used to set the userID for the shopping cart. All other functionality provided by the session bean is in fact provided by its superclass, the ShoppingCartBean. Note that any methods exposed in the session bean's remote interface must be declared public (which ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access