nerdexam
Oracle

1Z0-895 · Question #17

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…

The correct answer is B. @PostConstruct, @PreDestroy. The Lifecycle of a Stateless Session Bean The EJB container typically creates and maintains a pool of stateless session beans, beginning the stateless session bean's lifecycle. The container performs any dependency injection and then invokes the method annotated @PostConstruct…

Server Installation and Configuration

Question

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.)

Exhibit

1Z0-895 question #17 exhibit

Options

  • A@PostConstruct, @PostDestroy
  • B@PostConstruct, @PreDestroy
  • C@PreConstruct, @PostDestroy
  • D@PostConstruct, @PostDestroy, @Remove
  • E@PostConstruct, @PreDestroy, @Remove

How the community answered

(24 responses)
  • B
    71% (17)
  • C
    8% (2)
  • D
    17% (4)
  • E
    4% (1)

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 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 EJB container calls the method annotated @PreDestroy, if it exists. The bean's 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:

Topics

#lifecycle callbacks#PostConstruct#PreDestroy#stateless session bean

Community Discussion

No community discussion yet for this question.

Full 1Z0-895 Practice