private Object injectFields(BeanDefinition beanDefinition) { Object bean = BeanUtils.instantiate(beanDefinition.getBeanClass()); Set<Field> injectFields = beanDefinition.getInjectFields(); for (Field field : injectFields) { injectField(bean, field); } return bean; }
private Object inject(BeanDefinition beanDefinition) { if (beanDefinition.getResolvedInjectMode() == InjectType.INJECT_NO) { return BeanUtils.instantiate(beanDefinition.getBeanClass()); } else if (beanDefinition.getResolvedInjectMode() == InjectType.INJECT_FIELD) { return injectFields(beanDefinition); } else { return injectConstructor(beanDefinition); } }
private Object injectConstructor(BeanDefinition beanDefinition) { Constructor<?> constructor = beanDefinition.getInjectConstructor(); Object[] args = populateArguments(constructor.getParameterTypes()); return BeanUtils.instantiateClass(constructor, args); }