* @return
*/
private static DefaultListableBeanFactory createBeanFactory() {
return new DefaultListableBeanFactory() {
{
final InstantiationStrategy is = getInstantiationStrategy();
setInstantiationStrategy(new InstantiationStrategy() {
@Override
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) throws BeansException {
return is.instantiate(beanDefinition, beanName, owner);
}
@Override
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, Constructor<?> ctor, Object[] args) throws BeansException {
final Object bean = is.instantiate(beanDefinition, beanName, owner, ctor, args);
addDependencies(bean, args);
return bean;
}
@Override
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, Object factoryBean, Method factoryMethod, Object[] args) throws BeansException {
final Object bean = is.instantiate(beanDefinition, beanName, owner, factoryBean, factoryMethod, args);
addDependencies(bean, args);
return bean;
}
});
}