public class Baz implements InitializingBean, DisposableBean { @Override public void afterPropertiesSet() throws Exception { System.out.println("init method invoked"); } @Override public void destroy() throws Exception { System.out.println("destroy method invoked"); }}
// Need to have <context:annotation-config/> in the web.xml
public class Bar {
@PostConstruct
public void init() throws Exception {
System.out.println("init method is called");
}
@PreDestroy
public void destroy() throws RuntimeException {
System.out.println("destroy method is called");
}
}