One of my colleagues brought this up while he was practicing Spring 2.5 Knight example from Spring in Action.
While using AOP (the Minstrel example), if we use just the BeanFactory, we never get the log4j log messages.
Nor is there any error message etc. generated from Spring about why AOP did not work.
However, if we use ApplicationContext, those log messages are generated!
From a technical point of view, this seems fine because BeanFactory is the most basic container over which ApplicationContext is built.
Therefore, it may not be expected to support advanced concepts like AOP, transactions etc.
However, the absence of any error message from Spring can keep a newbie guessing for hours.
Submit a JIRA, shall I?
Christophe Verré wrote:Check this. There's no error because AOP will not take effect. It's not a bug.
I have already said that that AOP will not take effect is understood.
Thanks for your post, it is now clear that this is by design.
However, I don't understand why Spring chose to not throw an error/exception message when
somebody tries to make the BeanFactory work with AOP.
BeanFactory was created before AOP was introduced. BeanFactory does not have the lifecycle phase of BeanPostProcessesors, where the DynamicProxy objects are created for AOP, etc.
If they added AOP and this phase to BeanFactory, then it would break old code using BeanFactory, so to keep backwards compatibility it is better and easier to decorate the BeanFactory with the ApplicationContext.
You can't add exceptions or anything to BeanFactory or you would also break backwards compatibility.