Container Callbacks come from TWO places

image with no caption

For any session bean, you will always always always have at least five container callbacks—four from the SessionBean interface implementations, and at least one ejbCreate() to match the create() method declared in the home interface.

For stateless session beans, there will be exactly five container callbacks, since stateless session beans can have only one create() method. And since the stateless bean’s create() is always a no-arg, you know that the bean’s ejbCreate() will always be a no-arg.

For stateful beans, remember, there must be at least one create(), but there can be more, including both overloaded create() methods and create<something> methods. For example, a stateful bean home might have three create methods: create(), create(String s), createBigCustomer(String s). That would mean the bean would have three container callbacks from the home: ejbCreate(), ejbCreate(String s), ejbCreateBigCustomer(String s).

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.