接口 InstantiationStrategy

  • 所有已知实现类:
    CglibSubclassingInstantiationStrategy, SimpleInstantiationStrategy

    public interface InstantiationStrategy
    Interface responsible for creating instances corresponding to a root bean definition.

    This is pulled out into a strategy as various approaches are possible, including using CGLIB to create subclasses on the fly to support Method Injection.

    从以下版本开始:
    1.1
    作者:
    Rod Johnson, Juergen Hoeller
    • 方法详细资料

      • instantiate

        Object instantiate​(RootBeanDefinition bd,
                           @Nullable
                           String beanName,
                           BeanFactory owner)
                    throws BeansException
        Return an instance of the bean with the given name in this factory.
        参数:
        bd - the bean definition
        beanName - the name of the bean when it is created in this context. The name can be null if we are autowiring a bean which doesn't belong to the factory.
        owner - the owning BeanFactory
        返回:
        a bean instance for this bean definition
        抛出:
        BeansException - if the instantiation attempt failed
      • instantiate

        Object instantiate​(RootBeanDefinition bd,
                           @Nullable
                           String beanName,
                           BeanFactory owner,
                           Constructor<?> ctor,
                           Object... args)
                    throws BeansException
        Return an instance of the bean with the given name in this factory, creating it via the given constructor.
        参数:
        bd - the bean definition
        beanName - the name of the bean when it is created in this context. The name can be null if we are autowiring a bean which doesn't belong to the factory.
        owner - the owning BeanFactory
        ctor - the constructor to use
        args - the constructor arguments to apply
        返回:
        a bean instance for this bean definition
        抛出:
        BeansException - if the instantiation attempt failed
      • instantiate

        Object instantiate​(RootBeanDefinition bd,
                           @Nullable
                           String beanName,
                           BeanFactory owner,
                           @Nullable
                           Object factoryBean,
                           Method factoryMethod,
                           Object... args)
                    throws BeansException
        Return an instance of the bean with the given name in this factory, creating it via the given factory method.
        参数:
        bd - the bean definition
        beanName - the name of the bean when it is created in this context. The name can be null if we are autowiring a bean which doesn't belong to the factory.
        owner - the owning BeanFactory
        factoryBean - the factory bean instance to call the factory method on, or null in case of a static factory method
        factoryMethod - the factory method to use
        args - the factory method arguments to apply
        返回:
        a bean instance for this bean definition
        抛出:
        BeansException - if the instantiation attempt failed