Book Image

EJB 3 Developer Guide

By : Michael Sikora
Book Image

EJB 3 Developer Guide

By: Michael Sikora

Overview of this book

Table of Contents (18 chapters)
EJB 3 Developer Guide
Credits
About the Author
About the Reviewers
Preface
Annotations and Their Corresponding Packages

MDB LifeCycle


The MDB lifecycle is similar to the stateless session bean lifecycle. The following state diagram shows the MDB's lifecycle:

There are just two MDB lifecycle states: does-not-exist and method-ready pool. The initial state of an MDB is the does-not-exist state. This would be the case before a container starts up. The next state is the method-ready pool. When the container starts up it typically creates a number of MDB instances in the method-ready pool. However, the container can decide at any time to create such instances. In creating an instance in the method-ready pool, the container performs the following steps:

  1. 1. The MDB is instantiated.

  2. 2. The container injects the bean's MessageDrivenContext, if applicable.

  3. 3. The container performs any other dependency injection that is specified in the bean's metadata.

  4. 4. The container invokes a PostConstruct callback method if one is present in the bean. The PostConstruct method would be used for initializing any resources used by the...