Who creates what?

For a bean with a remote client view (in other words, a bean that can be accessed by remote clients), you know that you have to write the Component interface and the Bean class. But somebody has to write the class that implements your Component interface (to make the Remote EJBObject), and somebody has to make the stub that goes with that EJBObject. That somebody is the Container. And, though we haven’t yet talked about the Home, we’ve listed the relevant pieces here for completeness.

You

the Container

  1. The Component interface (extends javax.ejb.EJBObject)

  2. The Bean class (implements javax.ejb.SessionBean or javax.ejb.EntityBean)

  3. The Home interface (extends javax.ejb.EJBHome; we’ll talk about this on the next page)

  1. The EJBObject class (implements your Component interface)

  2. The EJBObject stub class (implements your Component interface and knows how to talk to the EJBObject)

  3. The Home class (implements your Home interface)

  4. The Home stub class (implements your Home interface and knows how to talk to the Home)

image with no caption

We haven’t talked about the Home yet, so we don’t show it on this picture.

Get Head First EJB 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.