BeanFactory注释翻译

这几天准备完成设计模式的课程设计,需要找到Spring Boot中的设计模式、设计案例以及调试分析,打算写几篇博客记录一下。

BeanFactory注释翻译

在源代码里面根据继承关系一步一步找到最顶层的BeanFactory接口,但是注释都是英文的,尝试翻译的结果如下,最上面关于协议的部分被我删掉了,简单说就是基于 Apache 2.0开源协议。细节可以自己去源代码中看看。一次性放下去就太长,一点一点解析吧。
首先是包的导入,这部分没啥好说的。

package org.springframework.beans.factory;

import org.springframework.beans.BeansException;
import org.springframework.core.ResolvableType;
import org.springframework.lang.Nullable;

然后是对接口的注释,因为把整段粘贴下来的话字是灰色的,不容易看清,所以把注释的标识去掉了,源代码中是有的。每段对应的翻译写在英文原文的下方,如有错漏请不吝指出。

 * The root interface for accessing a Spring bean container.
 * 这是访问Spring bean容器的根接口
 * 
 * <p>This is the basic client view of a bean container;
 * further interfaces such as {@link ListableBeanFactory} and
 * {@link org.springframework.beans.factory.config.ConfigurableBeanFactory}
 * are available for specific purposes.
 * 这是一个bean容器的基础客户端视图,以后的接口例如ListableBeanFactory和ConfigurableBeanFactory
 * 都是它的具体实现
 * 
 * <p>This interface is implemented by objects that hold a number of bean definitions,
 * each uniquely identified by a String name. Depending on the bean definition,
 * the factory will return either an independent instance of a contained object
 * (the Prototype design pattern), or a single shared instance (a superior
 * alternative to the Singleton design pattern, in which the instance is a
 * singleton in the scope of the factory). Which type of instance will be returned
 * depends on the bean factory configuration: the API is the same. Since Spring
 * 2.0, further scopes are available depending on the concrete application
 * context (e.g. "request" and "session" scopes in a web environment).
 * 这个接口通过持有大量bean定义的对象实现,通过String型的name唯一标识,根据bean的定义,工厂将会返回
 * 一个包含对象的独立示例(原型设计模式),或者一个单个共享的示例(单例模式的优秀替代,在工厂范围内的
 * 单例),返回哪一种示例取决于bean工厂的设置:API是相同的,从Spring2.0开始,更大的作用域取决于具体
 * 的应用程序上下文,(例如“request”和“session”在web环境下的作用域)
 * 
 * <p>The point of this approach is that the BeanFactory is a central registry
 * of application components, and centralizes configuration of application
 * components (no more do individual objects need to read properties files,
 * for example). See chapters 4 and 11 of "Expert One-on-One J2EE Design and
 * Development" for a discussion of the benefits of this approach.
 * 这种方法的要点在于BeanFactory是程序组件的注册中心和集中配置的地方,(例如没有其它独立对象需要访问
 * 配置文件)“Expert One-on-One J2EE Design and Development”的第四和十一章讨论了这种方法的好处
 * 
 * <p>Note that it is generally better to rely on Dependency Injection
 * ("push" configuration) to configure application objects through setters
 * or constructors, rather than use any form of "pull" configuration like a
 * BeanFactory lookup. Spring's Dependency Injection functionality is
 * implemented using this BeanFactory interface and its subinterfaces.
 * 需要注意的是通常来说依靠依赖注入(”push“配置)通过setter和构造器来配置应用对象要比使用任何形式的
 * ”pull“配置例如BeanFactory查找更好,Spring的依赖注入功能是通过使用这个BeanFactory接口及其子接口
 * 实现的
 * 
 * <p>Normally a BeanFactory will load bean definitions stored in a configuration
 * source (such as an XML document), and use the {@code org.springframework.beans}
 * package to configure the beans. However, an implementation could simply return
 * Java objects it creates as necessary directly in Java code. There are no
 * constraints on how the definitions could be stored: LDAP, RDBMS, XML,
 * properties file, etc. Implementations are encouraged to support references
 * amongst beans (Dependency Injection).
 * 通常来说一个BeanFactory会在配置文件(如一个XML文档)中加载bean定义,然后使用beans包来设置bean,
 * 但是在这里,在java代码中必要时一个实现可以直接返回一个java对象,这里没有对定义的限制如LDAP,RDBMS,
 * XML,配置文件等,鼓励使用bean之间的引用(依赖注入)
 * 
 * <p>In contrast to the methods in {@link ListableBeanFactory}, all of the
 * operations in this interface will also check parent factories if this is a
 * {@link HierarchicalBeanFactory}. If a bean is not found in this factory instance,
 * the immediate parent factory will be asked. Beans in this factory instance
 * are supposed to override beans of the same name in any parent factory.
 * 与ListableBeanFactory中的方法相比,此接口中的所有操作还将检查父工厂是否为HierarchicalBeanFactory。
 * 如果在这个工厂实例中没有找到bean,就会询问直接的父工厂。这个工厂实例中的bean应该覆盖任何父工厂中同
 * 名的bean。
 * 
 * <p>Bean factory implementations should support the standard bean lifecycle interfaces
 * as far as possible. The full set of initialization methods and their standard order is:
 * Bean工厂实现应该尽可能地支持标准bean lifecycle接口,所有实例方法和他们的标准排序如下
 * <ol>
 * <li>BeanNameAware's {@code setBeanName}
 * <li>BeanClassLoaderAware's {@code setBeanClassLoader}
 * <li>BeanFactoryAware's {@code setBeanFactory}
 * <li>EnvironmentAware's {@code setEnvironment}
 * <li>EmbeddedValueResolverAware's {@code setEmbeddedValueResolver}
 * <li>ResourceLoaderAware's {@code setResourceLoader}
 * (only applicable when running in an application context)
 * <li>ApplicationEventPublisherAware's {@code setApplicationEventPublisher}
 * (only applicable when running in an application context)
 * <li>MessageSourceAware's {@code setMessageSource}
 * (only applicable when running in an application context)
 * <li>ApplicationContextAware's {@code setApplicationContext}
 * (only applicable when running in an application context)
 * <li>ServletContextAware's {@code setServletContext}
 * (only applicable when running in a web application context)
 * <li>{@code postProcessBeforeInitialization} methods of BeanPostProcessors
 * <li>InitializingBean's {@code afterPropertiesSet}
 * <li>a custom init-method definition
 * <li>{@code postProcessAfterInitialization} methods of BeanPostProcessors
 * </ol>
 *
 * <p>On shutdown of a bean factory, the following lifecycle methods apply:
 * 关闭bean工厂时,下列的lifecycle方法将会被调用
 * <ol>
 * <li>{@code postProcessBeforeDestruction} methods of DestructionAwareBeanPostProcessors
 * <li>DisposableBean's {@code destroy}
 * <li>a custom destroy-method definition
 * </ol>
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @author Chris Beams
 * @since 13 April 2001
 * @see BeanNameAware#setBeanName
 * @see BeanClassLoaderAware#setBeanClassLoader
 * @see BeanFactoryAware#setBeanFactory
 * @see org.springframework.context.ResourceLoaderAware#setResourceLoader
 * @see org.springframework.context.ApplicationEventPublisherAware#setApplicationEventPublisher
 * @see org.springframework.context.MessageSourceAware#setMessageSource
 * @see org.springframework.context.ApplicationContextAware#setApplicationContext
 * @see org.springframework.web.context.ServletContextAware#setServletContext
 * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization
 * @see InitializingBean#afterPropertiesSet
 * @see org.springframework.beans.factory.support.RootBeanDefinition#getInitMethodName
 * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization
 * @see DisposableBean#destroy
 * @see org.springframework.beans.factory.support.RootBeanDefinition#getDestroyMethodName
 * 作者、启用日期、引用此接口的包

然后就到了接口的本体,还是将注释的标识去掉了,语句前有星号则表示被注释了,仅翻译了目的,参数和异常没有翻译。

public interface BeanFactory {

	 * Used to dereference a {@link FactoryBean} instance and distinguish it from
	 * beans <i>created</i> by the FactoryBean. For example, if the bean named
	 * {@code myJndiObject} is a FactoryBean, getting {@code &myJndiObject}
	 * will return the factory, not the instance returned by the factory.
	 * 用于废弃一个FactoryBean示例并且将它和被FactoryBean创建的bean区分开来,举个例子:如果一个
	 * beanFactory名为myJndiObject,那么 &myJndiObject将会返回工厂,而不是被工厂返回的示例。
	String FACTORY_BEAN_PREFIX = "&";

	 * Return an instance, which may be shared or independent, of the specified bean.
	 * <p>This method allows a Spring BeanFactory to be used as a replacement for the
	 * Singleton or Prototype design pattern. Callers may retain references to
	 * returned objects in the case of Singleton beans.
	 * <p>Translates aliases back to the corresponding canonical bean name.
	 * <p>Will ask the parent factory if the bean cannot be found in this factory instance.
	 * @param name the name of the bean to retrieve
	 * @return an instance of the bean
	 * @throws NoSuchBeanDefinitionException if there is no bean with the specified name
	 * @throws BeansException if the bean could not be obtained
	 * 返回一个指定bean的实例,可能是共享的,也可能是独立的
	 * 这个方法运行Spring BeanFactory被用作单例设计模式或原型设计模式的替代,当使用单例模式时,
	 * 调用者可能保留对返回对象的引用
	 * 将别名翻译回相应的规范bean名称
	 * 如果在此工厂找不到实例将会访问父工厂。
	Object getBean(String name) throws BeansException;

	 * Return an instance, which may be shared or independent, of the specified bean.
	 * <p>Behaves the same as {@link #getBean(String)}, but provides a measure of type
	 * safety by throwing a BeanNotOfRequiredTypeException if the bean is not of the
	 * required type. This means that ClassCastException can't be thrown on casting
	 * the result correctly, as can happen with {@link #getBean(String)}.
	 * <p>Translates aliases back to the corresponding canonical bean name.
	 * <p>Will ask the parent factory if the bean cannot be found in this factory instance.
	 * @param name the name of the bean to retrieve
	 * @param requiredType type the bean must match; can be an interface or superclass
	 * @return an instance of the bean
	 * @throws NoSuchBeanDefinitionException if there is no such bean definition
	 * @throws BeanNotOfRequiredTypeException if the bean is not of the required type
	 * @throws BeansException if the bean could not be created
	 * 返回一个指定bean的实例,可能是共享的,也可能是独立的
	 * 行为与getBean(String)相同,但如果bean不是要求的类型,会抛出BeanNotOfRequiredTypeException
	 * 以提供类型安全的考量,这意味着在getBean(String)中为了转换到正确的类型可能出现的
	 * ClassCastException在这里不会被抛出。
	 * 将别名翻译回相应的规范bean名称
	 * 如果在此工厂找不到实例将会访问父工厂。
	<T> T getBean(String name, Class<T> requiredType) throws BeansException;

	 * Return an instance, which may be shared or independent, of the specified bean.
	 * <p>Allows for specifying explicit constructor arguments / factory method arguments,
	 * overriding the specified default arguments (if any) in the bean definition.
	 * @param name the name of the bean to retrieve
	 * @param args arguments to use when creating a bean instance using explicit arguments
	 * (only applied when creating a new instance as opposed to retrieving an existing one)
	 * @return an instance of the bean
	 * @throws NoSuchBeanDefinitionException if there is no such bean definition
	 * @throws BeanDefinitionStoreException if arguments have been given but
	 * the affected bean isn't a prototype
	 * @throws BeansException if the bean could not be created
	 * @since 2.5
	 * 返回一个指定bean的实例,可能是共享的,也可能是独立的
	 * 允许显式指定构造器参数/工厂方法参数,在bean的定义覆盖指定的默认参数(如果有)。
	Object getBean(String name, Object... args) throws BeansException;

	 * Return the bean instance that uniquely matches the given object type, if any.
	 * <p>This method goes into {@link ListableBeanFactory} by-type lookup territory
	 * but may also be translated into a conventional by-name lookup based on the name
	 * of the given type. For more extensive retrieval operations across sets of beans,
	 * use {@link ListableBeanFactory} and/or {@link BeanFactoryUtils}.
	 * @param requiredType type the bean must match; can be an interface or superclass
	 * @return an instance of the single bean matching the required type
	 * @throws NoSuchBeanDefinitionException if no bean of the given type was found
	 * @throws NoUniqueBeanDefinitionException if more than one bean of the given type was found
	 * @throws BeansException if the bean could not be created
	 * @since 3.0
	 * @see ListableBeanFactory
	 * 如果有,返回一个唯一匹配给出的对象类型的bean实例
	 * 这个方法基于给定的类型名称会进入ListableBeanFactory的by-type查找领域,也可能被翻译进入一个
	 * 普通的by-name查找,想要更多对于bean集合的检索操作,使用ListableBeanFactory 和/*  BeanFactoryUtils
	<T> T getBean(Class<T> requiredType) throws BeansException;

	 * Return an instance, which may be shared or independent, of the specified bean.
	 * <p>Allows for specifying explicit constructor arguments / factory method arguments,
	 * overriding the specified default arguments (if any) in the bean definition.
	 * <p>This method goes into {@link ListableBeanFactory} by-type lookup territory
	 * but may also be translated into a conventional by-name lookup based on the name
	 * of the given type. For more extensive retrieval operations across sets of beans,
	 * use {@link ListableBeanFactory} and/or {@link BeanFactoryUtils}.
	 * @param requiredType type the bean must match; can be an interface or superclass
	 * @param args arguments to use when creating a bean instance using explicit arguments
	 * (only applied when creating a new instance as opposed to retrieving an existing one)
	 * @return an instance of the bean
	 * @throws NoSuchBeanDefinitionException if there is no such bean definition
	 * @throws BeanDefinitionStoreException if arguments have been given but
	 * the affected bean isn't a prototype
	 * @throws BeansException if the bean could not be created
	 * @since 4.1
	 * 返回一个指定bean的实例,可能是共享的,也可能是独立的
	 * 允许显式指定构造器参数/工厂方法参数,在bean的定义覆盖指定的默认参数(如果有)。
	 * 这个方法基于给定的类型名称会进入ListableBeanFactory的by-type查找领域,也可能被翻译进入一个
	 * 普通的by-name查找,想要更多对于bean集合的检索操作,使用ListableBeanFactory 和/*  BeanFactoryUtils
	<T> T getBean(Class<T> requiredType, Object... args) throws BeansException;

	 * Return a provider for the specified bean, allowing for lazy on-demand retrieval
	 * of instances, including availability and uniqueness options.
	 * @param requiredType type the bean must match; can be an interface or superclass
	 * @return a corresponding provider handle
	 * @since 5.1
	 * @see #getBeanProvider(ResolvableType)
	 * 返回指定bean的提供者,允许对实例懒惰按需检索,包含可用性和唯一性选项
	<T> ObjectProvider<T> getBeanProvider(Class<T> requiredType);

	 * Return a provider for the specified bean, allowing for lazy on-demand retrieval
	 * of instances, including availability and uniqueness options.
	 * @param requiredType type the bean must match; can be a generic type declaration.
	 * Note that collection types are not supported here, in contrast to reflective
	 * injection points. For programmatically retrieving a list of beans matching a
	 * specific type, specify the actual bean type as an argument here and subsequently
	 * use {@link ObjectProvider#orderedStream()} or its lazy streaming/iteration options.
	 * @return a corresponding provider handle
	 * @since 5.1
	 * @see ObjectProvider#iterator()
	 * @see ObjectProvider#stream()
	 * @see ObjectProvider#orderedStream()
	 * 返回指定bean的提供者,允许对实例懒惰按需检索,包含可用性和唯一性选项
	<T> ObjectProvider<T> getBeanProvider(ResolvableType requiredType);

	 * Does this bean factory contain a bean definition or externally registered singleton
	 * instance with the given name?
	 * <p>If the given name is an alias, it will be translated back to the corresponding
	 * canonical bean name.
	 * <p>If this factory is hierarchical, will ask any parent factory if the bean cannot
	 * be found in this factory instance.
	 * <p>If a bean definition or singleton instance matching the given name is found,
	 * this method will return {@code true} whether the named bean definition is concrete
	 * or abstract, lazy or eager, in scope or not. Therefore, note that a {@code true}
	 * return value from this method does not necessarily indicate that {@link #getBean}
	 * will be able to obtain an instance for the same name.
	 * @param name the name of the bean to query
	 * @return whether a bean with the given name is present
	 * 用于判断这个bean工厂是否包含给定名称的bean定义或者外部注册了单例对象
	 * 如果传入的名称是别名,它将会被翻译回相应的规范bean名称
	 * 如果这个工厂是分层的,当在这个工厂实例找不到它将会访问所有的父工厂
	 * 如果一个bean定义或者单例实例匹配倒了指定名称,这个方法将会返回true,无论该定义是具体还是抽象,
	 * 懒惰或急切,在不在范围之内,因此需要注意,这个方法返回true的时候并不意味着getBean方法能够获得
	 * 同名的实例。
	boolean containsBean(String name);

	 * Is this bean a shared singleton? That is, will {@link #getBean} always
	 * return the same instance?
	 * <p>Note: This method returning {@code false} does not clearly indicate
	 * independent instances. It indicates non-singleton instances, which may correspond
	 * to a scoped bean as well. Use the {@link #isPrototype} operation to explicitly
	 * check for independent instances.
	 * <p>Translates aliases back to the corresponding canonical bean name.
	 * <p>Will ask the parent factory if the bean cannot be found in this factory instance.
	 * @param name the name of the bean to query
	 * @return whether this bean corresponds to a singleton instance
	 * @throws NoSuchBeanDefinitionException if there is no bean with the given name
	 * @see #getBean
	 * @see #isPrototype
	 * 判断该bean是否是共享的单例?也就是说,getBean方法总能返回同一个实例吗?
	 * 注意:这个方法返回false并不明确表示该bean是独立实例,他表明该bean是非单例对象,也有可能是因为
	 * 可见范围引起的,使用 isPrototype操作来直接检查独立实例。
	 * 将别名翻译回相应的规范bean名称
	 * 如果在此工厂找不到实例将会访问父工厂。
	boolean isSingleton(String name) throws NoSuchBeanDefinitionException;

	 * Is this bean a prototype? That is, will {@link #getBean} always return
	 * independent instances?
	 * <p>Note: This method returning {@code false} does not clearly indicate
	 * a singleton object. It indicates non-independent instances, which may correspond
	 * to a scoped bean as well. Use the {@link #isSingleton} operation to explicitly
	 * check for a shared singleton instance.
	 * <p>Translates aliases back to the corresponding canonical bean name.
	 * <p>Will ask the parent factory if the bean cannot be found in this factory instance.
	 * @param name the name of the bean to query
	 * @return whether this bean will always deliver independent instances
	 * @throws NoSuchBeanDefinitionException if there is no bean with the given name
	 * @since 2.0.3
	 * @see #getBean
	 * @see #isSingleton
	 * 判断该bean是否是一个原型?也就是说,getBean方法总能返回独立实例吗?
	 * 注意:这个方法返回false并不明确表示该bean是单例实例,他表明该bean是非单例对象,也有可能是因为
	 * 可见范围引起的,使用 isSingleton操作来直接检查单例实例。
	 * 将别名翻译回相应的规范bean名称
	 * 如果在此工厂找不到实例将会访问父工厂。
	boolean isPrototype(String name) throws NoSuchBeanDefinitionException;

	 * Check whether the bean with the given name matches the specified type.
	 * More specifically, check whether a {@link #getBean} call for the given name
	 * would return an object that is assignable to the specified target type.
	 * <p>Translates aliases back to the corresponding canonical bean name.
	 * <p>Will ask the parent factory if the bean cannot be found in this factory instance.
	 * @param name the name of the bean to query
	 * @param typeToMatch the type to match against (as a {@code ResolvableType})
	 * @return {@code true} if the bean type matches,
	 * {@code false} if it doesn't match or cannot be determined yet
	 * @throws NoSuchBeanDefinitionException if there is no bean with the given name
	 * @since 4.2
	 * @see #getBean
	 * @see #getType
	 * 检查给定名称的bean是否是指定类型
	 * 更具体的说,检查是否调用getBean方法查询给定名称会返回一个可以转换成指定目标类型的对象。
	 * 将别名翻译回相应的规范bean名称
	 * 如果在此工厂找不到实例将会访问父工厂。
	boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException;

	 * Check whether the bean with the given name matches the specified type.
	 * More specifically, check whether a {@link #getBean} call for the given name
	 * would return an object that is assignable to the specified target type.
	 * <p>Translates aliases back to the corresponding canonical bean name.
	 * <p>Will ask the parent factory if the bean cannot be found in this factory instance.
	 * @param name the name of the bean to query
	 * @param typeToMatch the type to match against (as a {@code Class})
	 * @return {@code true} if the bean type matches,
	 * {@code false} if it doesn't match or cannot be determined yet
	 * @throws NoSuchBeanDefinitionException if there is no bean with the given name
	 * @since 2.0.1
	 * @see #getBean
	 * @see #getType
	 * 检查给定名称的bean是否是指定类型
	 * 更具体的说,检查是否调用getBean方法查询给定名称会返回一个可以转换成指定目标类型的对象。
	boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException;

	 * Determine the type of the bean with the given name. More specifically,
	 * determine the type of object that {@link #getBean} would return for the given name.
	 * <p>For a {@link FactoryBean}, return the type of object that the FactoryBean creates,
	 * as exposed by {@link FactoryBean#getObjectType()}. This may lead to the initialization
	 * of a previously uninitialized {@code FactoryBean} (see {@link #getType(String, boolean)}).
	 * <p>Translates aliases back to the corresponding canonical bean name.
	 * <p>Will ask the parent factory if the bean cannot be found in this factory instance.
	 * @param name the name of the bean to query
	 * @return the type of the bean, or {@code null} if not determinable
	 * @throws NoSuchBeanDefinitionException if there is no bean with the given name
	 * @since 1.1.2
	 * @see #getBean
	 * @see #isTypeMatch
	 * 确定指定名称的bean的类型,更具体的说,确定getBean方法返回的指定名称的对象的类型。
	 * 对于FactoryBean,返回FactoryBean创建的对象的类型,可见于FactoryBean的getObjectType()* 这可能会导致初始化一个之前没有初始化的FactoryBean,(见getType)
	 * 将别名翻译回相应的规范bean名称
	 * 如果在此工厂找不到实例将会访问父工厂。	
	@Nullable
	Class<?> getType(String name) throws NoSuchBeanDefinitionException;

	 * Determine the type of the bean with the given name. More specifically,
	 * determine the type of object that {@link #getBean} would return for the given name.
	 * <p>For a {@link FactoryBean}, return the type of object that the FactoryBean creates,
	 * as exposed by {@link FactoryBean#getObjectType()}. Depending on the
	 * {@code allowFactoryBeanInit} flag, this may lead to the initialization of a previously
	 * uninitialized {@code FactoryBean} if no early type information is available.
	 * <p>Translates aliases back to the corresponding canonical bean name.
	 * <p>Will ask the parent factory if the bean cannot be found in this factory instance.
	 * @param name the name of the bean to query
	 * @param allowFactoryBeanInit whether a {@code FactoryBean} may get initialized
	 * just for the purpose of determining its object type
	 * @return the type of the bean, or {@code null} if not determinable
	 * @throws NoSuchBeanDefinitionException if there is no bean with the given name
	 * @since 5.2
	 * @see #getBean
	 * @see #isTypeMatch
	 * 确定指定名称的bean的类型,更具体的说,确定getBean方法返回的指定名称的对象的类型。
	 * 对于FactoryBean,返回FactoryBean创建的对象的类型,可见于FactoryBean的getObjectType()* 取决于allowFactoryBeanInit变量,如果没有早期类型信息可用,这可能会导致初始化一个之前没有初始化
	 * 的FactoryBean
	 * 将别名翻译回相应的规范bean名称
	 * 如果在此工厂找不到实例将会访问父工厂。
	@Nullable
	Class<?> getType(String name, boolean allowFactoryBeanInit) throws NoSuchBeanDefinitionException;

	 * Return the aliases for the given bean name, if any.
	 * <p>All of those aliases point to the same bean when used in a {@link #getBean} call.
	 * <p>If the given name is an alias, the corresponding original bean name
	 * and other aliases (if any) will be returned, with the original bean name
	 * being the first element in the array.
	 * <p>Will ask the parent factory if the bean cannot be found in this factory instance.
	 * @param name the bean name to check for aliases
	 * @return the aliases, or an empty array if none
	 * @see #getBean
	 * 如果有的话,返回指定名称的bean的别名
	 * 当调用getBean时,所有的别名执行同一个bean
	 * 如果指定的名称是一个别名,那么将会返回原始的规范名称和其它别名(如果有的话),原始的规范名称是
	 * 数组中的第一个元素
	 * 如果在此工厂找不到实例将会访问父工厂。
	String[] getAliases(String name);
}

那么通过以上的翻译可以看出BeanFactory的子接口中可能用到两种设计模式,原型设计模式和单例设计模式。

其它

1.Spring Boot中好多都有两个构造器,在空参构造器中传入参数调用自身的含参构造器。
2.本来想找java doc文档的,但是在eclipse中弄半天弄不出来,maven项目,下载了源代码和java doc,但是build path中总是显示 Archive can not be found in file system,点击验证弹出的信息说找不到’package-list’和’index.html’,弄不明白,就算了,应该是java doc的结构要求,先看着源代码吧。
3.本来是打算记录完整的过程的,但是后来发现一个一个翻译会花费很长时间,所以就没有继续翻译了,因为在学习的过程中也看了很多文章,就贴在下面,各位也可以看看。是写在课程设计的报告里面的,我也不清楚能不能引用网络博客和文献,各位如果有需要就问一下指导老师,虽然我也没问(狗头)
4.一开始阅读源代码的时候,只会一点点看,然后点击ctrl跳转到声明的地方,现在我学会了另外的方式,(在eclipse中,其它不清楚)比如选中一个类名,点击右键,找到References,如果选择Project就是在以Project的形式查找引用,如果选择Hierarchy就是查找继承引用,References下方的Declarations则是查找声明,大致是这么理解的;Spring Boot中很多地方直接使用ctrl跳转会跳转到接口去,这时候可以放置断点,然后在变量块中找到具体的实现类的名称,名称通常都是全类名,此时就可以在茫茫jar包之中精准定位了,
5.然后找到了一个具体的实例类以后,如果类的结构太复杂,可以直接将类名作为关键词进行百度搜索,网络上有很多能人志士研究过Spring Boot,也许你正在看的这个类别人已经研究过了,并且翻译出中文,这时候就可以更轻松地掌握了,当然也要注意会不会因为版本迭代而过时。
6.这里还要说一下我总感觉Spring Boot中的监听器不是直接应用了观察者模式,它是维护了一个Listener名称的Map(具体类型没仔细看),然后调用方法的时候是用反射去调用的,我总觉得这个和我理解的观察者模式不太一样,但是网上好多资料都在说,时间紧迫,我就写上去了。
最后大家喜欢的话请点赞收藏支持一下,有什么问题也可以在评论区说说,我有看到就会回复。

[1]Spring Boot.[EB/OL].https://baike.baidu.com/item/Spring%20Boot,2020-04-04
[2]一曲畔上.Spring Boot的Log日志系统详解.[EB/OL].https://www.jianshu.com/p/5716eadbd12d,2020-01-04
[3]MONKEY_D_MENG.UML类图新手入门级介绍.[EB/OL].https://blog.csdn.net/monkey_d_meng/article/details/6005764,2010-11-12
[4]fei1234456.Spring/SpringBoot系列之Spring中涉及的9种设计模式.[EB/OL].https://blog.csdn.net/fei1234456/article/details/106693892,2020-06-11
[5]Choice.Spring Boot 单例 怎么实现并发请求处理的.[EB/OL].https://www.zhihu.com/question/283426365,2018-07-04
[6]雨点的名字.SpringBoot(14)-注解装配Bean.[EB/OL].https://www.cnblogs.com/qdhxhz/p/11006289.html,2019-06-11
[7]Lambda程序员.面试题:Spring为什么默认bean为单例.[EB/OL].https://blog.csdn.net/pyycsd/article/details/102803271,2019-10-24
[8]大军.spring学习之源码分析–AbstractBeanFactory.[EB/OL].https://segmentfault.com/a/1190000020912773,2019-11-05
[9]00u0o.spring的controller默认是单例还是多例.[EB/OL].https://blog.csdn.net/q1512451239/article/details/53122687,2016-11-10
[10]斗者_2013.spring怎么实现单例模式.[EB/OL].https://blog.csdn.net/w1014074794/article/details/88403568,2019-03-11
[11]Mr_小白不白.DefalutSingletonBeanRegistry.[EB/OL].https://blog.csdn.net/xiaobai51509660/article/details/42610741,2015-01-11
[12]一问三不知.SpringBoot2.0监听器ApplicationListener的使用-监听ApplicationReadyEvent事件.[EB/OL].https://www.cnblogs.com/JoeyWong/p/9050189.html,2018-05-17
[13]分享牛.spring boot监听器使用.[EB/OL]. http://www.shareniu.com/article/73.htm,2017-04-18
[14]gdwkong. SpringBoot – 事件(Application Event).[EB/OL].https://www.cnblogs.com/gdwkong/p/9309459.html,2018-07-14
[15]恒宇少年. 第二十七章:SpringBoot使用ApplicationEvent&Listener完成业务解耦.[EB/OL].https://segmentfault.com/a/1190000011433514,2017-10-01
[16]JMCui.Spring 中的观察者模式.[EB/OL].https://www.cnblogs.com/jmcui/p/11054756.html,2019-06-20
[17]黄-jamison.Spring设计模式剖析之观察者模式.[EB/OL].https://blog.csdn.net/qq_25928361/article/details/107129449,2020-07-04
[18]Swing_wingS.用设计模式学springboot源码合集一:观察者模式下的springboot监听.[EB/OL].https://blog.csdn.net/Swing_wingS/article/details/105544199,2020-04-15
[19]发现存在.spring-事件机制-监听器-观察者模式.[EB/OL].https://blog.csdn.net/yunduanyou/article/details/107123434,2020-07-04
[20]jwfy.Spring Event事件通知机制 源码学习.[EB/OL].https://www.jianshu.com/p/21984b08875c,2018-03-24

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值