美文网首页
org.springframework.beans.factor

org.springframework.beans.factor

作者: moralok | 来源:发表于2020-04-15 18:24 被阅读0次
    package org.springframework.beans.factory;
    
    /**
     * Interface to be implemented by beans that want to be aware of their
     * bean name in a bean factory. Note that it is not usually recommended
     * that an object depends on its bean name, as this represents a potentially
     * brittle dependence on external configuration, as well as a possibly
     * unnecessary dependence on a Spring API.
     *
     * <p>For a list of all bean lifecycle methods, see the
     * {@link BeanFactory BeanFactory javadocs}.
     *
     * @author Juergen Hoeller
     * @author Chris Beams
     * @since 01.11.2003
     * @see BeanClassLoaderAware
     * @see BeanFactoryAware
     * @see InitializingBean
     */
    public interface BeanNameAware extends Aware {
    
        /**
         * Set the name of the bean in the bean factory that created this bean.
         * <p>Invoked after population of normal bean properties but before an
         * init callback such as {@link InitializingBean#afterPropertiesSet()}
         * or a custom init-method.
         * @param name the name of the bean in the factory.
         * Note that this name is the actual bean name used in the factory, which may
         * differ from the originally specified name: in particular for inner bean
         * names, the actual bean name might have been made unique through appending
         * "#..." suffixes. Use the {@link BeanFactoryUtils#originalBeanName(String)}
         * method to extract the original bean name (without suffix), if desired.
         */
        void setBeanName(String name);
    
    }
    
    

    简介

    org.springframework.beans.factory.Aware 的一个子接口。

    文档

    想要知道它在 bean 工厂 中的 bean 名称bean 所实现的接口。 请注意,通常不建议一个对象依赖于它的 bean 名称,因为这表示对外部配置潜在的脆弱依赖,以及对 Spring API 的不必要依赖。

    有关所有 bean生命周期 方法的列表,请参见 BeanFactory javadocs

    在创建此 beanbean工厂 中设置 bean 名称。在填充常规 bean 属性 之后但在初始化回调(例如 InitializingBean#afterPropertiesSet() 或自定义的初始化方法)之前调用。
    @param name 工厂中的 bean 名称
    请注意,该名称是工厂中使用的实际 bean名称,可能与最初指定的名称不同:特别是对于 内部 bean 名称,通过添加“#...”后缀可以使实际bean名称具有唯一性。 如果需要,可以使用BeanFactoryUtils#originalBeanName(String)方法提取原始 bean名称(不带后缀)。

    相关文章

      网友评论

          本文标题:org.springframework.beans.factor

          本文链接:https://www.haomeiwen.com/subject/fhuqvhtx.html