接口 InstantiationAwareBeanPostProcessor

    • 方法详细资料

      • postProcessAfterInstantiation

        boolean postProcessAfterInstantiation​(Object bean,
                                              String beanName)
                                       throws BeansException
        Perform operations after the bean has been instantiated, via a constructor or factory method, but before Spring property population (from explicit properties or autowiring) occurs.

        This is the ideal callback for performing custom field injection on the given bean instance, right before Spring's autowiring kicks in.

        参数:
        bean - the bean instance created, with properties not having been set yet
        beanName - the name of the bean
        返回:
        true if properties should be set on the bean; false if property population should be skipped. Normal implementations should return true. Returning false will also prevent any subsequent InstantiationAwareBeanPostProcessor instances being invoked on this bean instance.
        抛出:
        BeansException - in case of errors
        另请参阅:
        postProcessBeforeInstantiation(java.lang.Class<?>, java.lang.String)
      • postProcessPropertyValues

        PropertyValues postProcessPropertyValues​(PropertyValues pvs,
                                                 PropertyDescriptor[] pds,
                                                 Object bean,
                                                 String beanName)
                                          throws BeansException
        Post-process the given property values before the factory applies them to the given bean. Allows for checking whether all dependencies have been satisfied, for example based on a "Required" annotation on bean property setters.

        Also allows for replacing the property values to apply, typically through creating a new MutablePropertyValues instance based on the original PropertyValues, adding or removing specific values.

        参数:
        pvs - the property values that the factory is about to apply (never null)
        pds - the relevant property descriptors for the target bean (with ignored dependency types - which the factory handles specifically - already filtered out)
        bean - the bean instance created, but whose properties have not yet been set
        beanName - the name of the bean
        返回:
        the actual property values to apply to the given bean (can be the passed-in PropertyValues instance), or null to skip property population
        抛出:
        BeansException - in case of errors
        另请参阅:
        MutablePropertyValues