How does it all work?

Your beans run under the control (and protection) of the EJB server.

The server steps into the middle of every method call from a client to a bean and inserts the “services” like security, transactions, and persistence.

Your beans live and run in the server, and the server does virtually everything to manage transactions, security, persistence, and even the life and death of your objects. And it does all this by stepping in each time a client makes a request (i.e. calls a business method on the bean). The server jumps in and starts asking questions like:

“Does this client have security clearance to call this method?” or

“Does this bean need to run as part of a larger transaction?” or

“Does this bean need to refresh itself with data from the database, before running that method for the client?”

image with no caption

A ridiculously high-level view of EJB architecture

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.