calling method after properties are set in Spring


if you want to call a method which you want to be run after all the injections are done just do the following:

1. Make your class implement org.springframework.beans.factory.InitializingBean
2. override afterPropertiesSet method

and that is it. Sample code will be like:

public class MyBean implements InitializingBean {

private MyDao dao;

private MyOtherDao otherDao;

public void afterPropertiesSet() throws Exception {
System.out.println("this will be called after all the setters are done.");