Explain the life cycle of Stateless Session Bean.

Answered

Explain the life cycle of Stateless Session Bean.

Ninja Asked on 18th September 2018 in EJB 3.x.
Add Comment
1 Answer(s)
Best answer

The life cycle of a stateless session bean has two states:

  1. Does not exist
  2. Method ready pool

The container typically creates and maintains a pool of stateless session beans, marking the beginning of the stateless session bean’s lifecycle. The container performs any dependency injection and then invokes the method annotated @PostConstruct, if it exists. The bean is now ready to have its business methods invoked by a client. At the end of the lifecycle, the container calls the method annotated with @PreDestroy, if it exists. The bean’s instance is then ready for garbage collection.

The life cycle of stateless session bean can be understood with the following diagram.

Ninja Answered on 18th September 2018.
Add Comment