Designing the Stateful Session Bean

Like other enterprise beans, stateful session beans consist of a home interface, component interface, enterprise bean class, and deployment descriptor. The home and component interfaces can be local, or remote, or both.

Figure 6.2 shows the design of the EnrollmentCart component. The EnrollmentCart stateful session bean implements the SessionBean interface. It implements the methods setSessionContext(), ejbCreate(), ejbActivate(), ejbPassivate(), and ejbRemove() as defined in the javax.ejb.SessionBean interface. In addition, it implements the addCourses(String[] courseIds) method, which accepts an array of course IDs and adds them to the cart. The getCourses() method returns a collection of course IDs in the ...

Get Sams Teach Yourself EJB in 21 Days 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.