org.springframework.beans.factory.support

Interface InstantiationStrategy

  • All Known Implementing Classes:
    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.

    Since:
    1.1
    Author:
    Rod Johnson, Juergen Hoeller
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      java.lang.Object instantiate(RootBeanDefinition bd, java.lang.String beanName, BeanFactory owner)
      Return an instance of the bean with the given name in this factory.
      java.lang.Object instantiate(RootBeanDefinition bd, java.lang.String beanName, BeanFactory owner, java.lang.reflect.Constructor<?> ctor, java.lang.Object... args)
      Return an instance of the bean with the given name in this factory, creating it via the given constructor.
      java.lang.Object instantiate(RootBeanDefinition bd, java.lang.String beanName, BeanFactory owner, java.lang.Object factoryBean, java.lang.reflect.Method factoryMethod, java.lang.Object... args)
      Return an instance of the bean with the given name in this factory, creating it via the given factory method.
    • Method Detail

      • instantiate

        java.lang.Object instantiate(RootBeanDefinition bd,
                                     @Nullable
                                     java.lang.String beanName,
                                     BeanFactory owner)
                              throws BeansException
        Return an instance of the bean with the given name in this factory.
        Parameters:
        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
        Returns:
        a bean instance for this bean definition
        Throws:
        BeansException - if the instantiation attempt failed
      • instantiate

        java.lang.Object instantiate(RootBeanDefinition bd,
                                     @Nullable
                                     java.lang.String beanName,
                                     BeanFactory owner,
                                     java.lang.reflect.Constructor<?> ctor,
                                     java.lang.Object... args)
                              throws BeansException
        Return an instance of the bean with the given name in this factory, creating it via the given constructor.
        Parameters:
        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
        Returns:
        a bean instance for this bean definition
        Throws:
        BeansException - if the instantiation attempt failed
      • instantiate

        java.lang.Object instantiate(RootBeanDefinition bd,
                                     @Nullable
                                     java.lang.String beanName,
                                     BeanFactory owner,
                                     @Nullable
                                     java.lang.Object factoryBean,
                                     java.lang.reflect.Method factoryMethod,
                                     java.lang.Object... args)
                              throws BeansException
        Return an instance of the bean with the given name in this factory, creating it via the given factory method.
        Parameters:
        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
        Returns:
        a bean instance for this bean definition
        Throws:
        BeansException - if the instantiation attempt failed