Which of the following life cycle back annotations would you use?

Assume you would like to receive notification from the container as a stateless session bean
transitions to and from the ready state.
Which of the following life cycle back annotations would you use? (Choose one.)

Assume you would like to receive notification from the container as a stateless session bean
transitions to and from the ready state.
Which of the following life cycle back annotations would you use? (Choose one.)

A.
@PostConstruct, @PostDestroy

B.
@PostConstruct, @PreDestroy

C.
@PreConstruct, @PostDestroy

D.
@PostConstruct, @PostDestroy, @Remove

E.
@PostConstruct, @PreDestroy, @Remove

Explanation:
The Lifecycle of a Stateless Session Bean
The EJB container typically creates and maintains a pool of stateless session beans, beginning
the stateless session beans 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 EJB container calls the method annotated @PreDestroy, if it exists.
The beans instance is then ready for garbage collection.

Lifecycle of a Stateless Session Bean:

Note: An enterprise bean goes through various stages during its lifetime, or lifecycle. Each type of
enterprise bean (stateful session, stateless session, singleton session, or message-driven) has a
different lifecycle.
Reference: http://docs.oracle.com/javaee/6/tutorial/doc/giplj.html



Leave a Reply 2

Your email address will not be published. Required fields are marked *


JavaBatman

JavaBatman

Nope its B!