工厂方法模式:

AbstractBeanFactory.getObject()

  1. @Override
  2. public final T getObject() throws Exception {
  3. if (isSingleton()) {
  4. return (this.initialized ? this.singletonInstance : getEarlySingletonInstance());
  5. }
  6. else {
  7. return createInstance();
  8. }
  9. }
  10. protected abstract T createInstance() throws Exception;

createInstance() 由 AbstractBeanFactory 的子类去实现。
image.png