org.springframework.beans.factory.InitializingBean interface exactly specifies following one method:
void afterPropertiesSet() throws Exception;
But this is not a good approach as code will be coupled with Spring. So Spring have an feature .In XML-based configuration metadata, this can be done using the 'init-method' attribute.
<bean id="sampleInitBean" class="sample.SampleBean" init-method="init"/>
public class SampleBean {
public void init() {
// initialization code
}
}
This code is same as
<bean id="sampleInitBean" class="sample.AnotherSampleBean"/>
public class SampleExampleBean implements InitializingBean {
public void afterPropertiesSet() {
// initialization coding
}
}