MessageDrivenContext

The server makes message-driven beans virtually the same way in which it makes stateless session beans.

  1. Call the bean’s constructor (must be no-arg).

  2. Call the bean’s context setter.

  3. Call the beans ejbCreate() method.

In fact, the first two steps are the same for all bean types. The context setter always comes immediately after the bean’s constructor, and at some point before ejbCreate(). (And of course an entity bean might never get an ejbCreate() call, if there aren’t any clients trying to insert new entities into the database.)

So, what can a message-driven bean do with its context? We think it’s time for you to figure that out. We can guarantee there will be questions on the exam related to what a message-driven bean can and cannot do with its context. In fact, you’ll find these questions scattered throughout the objectives, not just in the message-driven bean objectives (10.1 – 10.4). Questions from the transactions, exceptions, and security objectives might involve a message-driven bean and its context.

This is just our way of saying.. do the damn exercise!

You don’t want to have to memorize this stuff, but if you just spend a few moments thinking about it, you’ll figure it out.

The answers are on the next page, though, so don’t turn until you’re done.

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.