The Remote object is not the bean, it’s the bean’s bodyguard—the EJBObject

Both the Remote object and the stub implement the same interface—the business interface (called a Component interface)—but without the real business logic behavior.

The bean class does NOT implement the business interface (in the formal Java way), but the bean has the real business logic functionality.

In EJB, remember, the Remote object (EJBObject) is the bean’s bodyguard. The bean sits back, protected from all client invocations, while the EJBObject implements the Remote interface and takes the remote calls. Once the call gets to the EJBObject, the server jumps in with all the services, like security (is this client authorized to call this method?), transactions (is this call part of an existing transaction, or should we start another transaction?), and persistence (does the bean need to load info from the database before running the client’s method?).

The EJBObject implements the Remote business interface, so the remote calls from the client come to the EJBObject. But it’s still the bean that has the real business logic, even though the bean doesn’t implement the Remote interface in the technical Java way.

image with no caption

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.