my bean.xml
hi friends.., i am just learning spring . i implement the interface BeanPostProcessor in HelloWorld.java . its methods invoked for all other beans , but not itself(Helloworld.java bean)
<bean id="helloWorld" class="com.tutorialspoint.HelloWorld" > </bean>
<!-- Definition for textEditor bean -->
<bean id="textEditor" class="com.tutorialspoint.TextEditor">
<property name="spellChecker" ref="spellChecker"/>
</bean>
<!-- Definition for spellChecker bean -->
<bean id="spellChecker" class="com.tutorialspoint.SpellChecker">
</bean>
Helloworld.java
public class HelloWorld implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization(Object bean, String name)
throws BeansException {
System.out.println();
System.out.println(bean.getClass().getName() +"---------------"+name+"--->This is after bean initialized ");
return bean;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String name)
throws BeansException {
System.out.println(bean.getClass().getName() +"---------------"+name+"----------->This is before bean initialized ");
return bean;
}
}
main program
public class MainApp {
public static void main(String arg[])throws Exception{
AbstractApplicationContext context = new ClassPathXmlApplicationContext("Bean.xml");
}
}
my output is
com.tutorialspoint.SpellChecker---------------spellChecker----------->This is before bean initialized
com.tutorialspoint.SpellChecker---------------spellChecker--->This is after bean initialized
com.tutorialspoint.TextEditor---------------textEditor----------->This is before bean initialized
com.tutorialspoint.TextEditor---------------textEditor--->This is after bean initialized
why BeanPostProcessor interface methods not invoked for HelloWorld.java ..,but invoked for other unrelated beans which is not implementing BeanPostProcessor interface ..?