Architectural overview: Entity beans

Clients share the Home, and may share the bean.

Each client has his own reference to the one and only Home for this bean (say, CustomerBean). But, if two clients are trying to access the same Customer (Fred Smith #420), then both clients have a reference to the same EJBObject. The EJBObject for #420. In other words, the EJBObject is the bodyguard for a particular Customer (like Fred Smith). If all the clients are trying to access Fred Smith #420, they will each have their own stub, of course, but all stubs will communicate with the same Remote EJBObject. And there will be only one bean representing Fred Smith #420. If a client wants to access two different customers, though, the client will have two stubs, and those stubs will be for two different EJBObjects, one for each customer. And that also means two different beans.

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.