Methods in the bean class may be declared as a lifecycle callback method by annotating the method with the following annotations:
javax.annotation.PostConstruct
javax.annotation.PreDestroy
javax.ejb.PostActivate
javax.ejb.PrePassivate
Lifecycle callback methods must return void and have no parameters.
@PostConstruct methods are invoked by the container on newly constructed bean instances after all dependency injection has completed and before the first business method is invoked on the enterprise bean.
@PreDestroy methods are invoked after any method annotated @Remove has completed, and before the container removes the enterprise bean instance.
@PostActivate methods are invoked by the container after the container moves the bean from secondary storage to active status.
@PrePassivate methods are invoked by the container before the container passivates the enterprise bean, meaning the container temporarily removes the bean from the environment and saves it to secondary storage.