Explain the life cycle of Stateless Session Bean.
The life cycle of a stateless session bean has two states:
- Does not exist
- 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.