Class SimpleInstantiationStrategy

    • Method Detail

      • getCurrentlyInvokedFactoryMethod

        @Nullable
        public static Method getCurrentlyInvokedFactoryMethod()
        Return the factory method currently being invoked or null if none.

        Allows factory method implementations to determine whether the current caller is the container itself as opposed to user code.

      • instantiateWithMethodInjection

        protected Object instantiateWithMethodInjection​(RootBeanDefinition bd,
                                                        @Nullable
                                                        String beanName,
                                                        BeanFactory owner)
        Subclasses can override this method, which is implemented to throw UnsupportedOperationException, if they can instantiate an object with the Method Injection specified in the given RootBeanDefinition. Instantiation should use a no-arg constructor.
      • instantiate

        public Object instantiate​(RootBeanDefinition bd,
                                  @Nullable
                                  String beanName,
                                  BeanFactory owner,
                                  Constructor<?> ctor,
                                  Object... args)
        Description copied from interface: InstantiationStrategy
        Return an instance of the bean with the given name in this factory, creating it via the given constructor.
        Specified by:
        instantiate in interface InstantiationStrategy
        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
      • instantiate

        public Object instantiate​(RootBeanDefinition bd,
                                  @Nullable
                                  String beanName,
                                  BeanFactory owner,
                                  @Nullable
                                  Object factoryBean,
                                  Method factoryMethod,
                                  Object... args)
        Description copied from interface: InstantiationStrategy
        Return an instance of the bean with the given name in this factory, creating it via the given factory method.
        Specified by:
        instantiate in interface InstantiationStrategy
        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