Container Callbacks, for the special moments in a bean’s life...

image with no caption

As a Bean Provider, YOU must implement container callbacks in your bean class!

When a bean has a special moment, it doesn’t know until the Container calls one of the bean’s container callback methods. These are special methods the Container knows about, that you (the Bean Provider) must implement in your bean class. You can think of the container callbacks as being kind of like event handlers.

Container callbacks come from two places: your bean’s home interface, and the SessionBean interface your session bean class must implement.

For a session bean, the home-related container callbacks are matching creation methods (ejbCreate()) for each create() method declared in the bean’s home interface.

The SessionBean interface declares four container callback methods for giving the bean its bean context, activating it, passivating it, and removing it. We’ll look at the actual methods on the next page.

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.