/**
* author Ding Chengyun
* 2015-2-11
*/
package test;
/**
* The root interface for accessing a Spring bean container.
* 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.
*
* 译:访问spring bean 容器的基础(根)接口
* 这是查看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定义的对象实现,每一个对象都有唯一确定字符串名字。根据bean定义,
* 工厂会返回一个独立的对象的实例(prototype设计模式),或者返回一个单例共享的实例(更好的单例设计模式是在工厂内单例)
* 返回那种类型的对象的实例取决于bean工厂的配置:API是一样的。
* 从spring2.0开始,根据具体的应用程序上下文可以选择更多的范围(scope,实例的类型),
* 比如在web环境中可以用request、session等
*
* <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"这本书的第4章和11章,
*
* <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.
*
* 译:注意,通常推荐使用setter方法或者构造方法的方式去配置应用程序对象的依赖注入(“push”,推的配置),
* 而不是拉 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定义,
* 并且使用org.springframework.beans这个包去配置这些beans。
* 然而,一个实现可以简单的返回Java对象,它创建必要的java代码。
* 对于bean定义如何存储没有限制:例如,Ldap、rdbms、xml、properties files。
* 实现方式鼓励使用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:<br>
* 1. BeanNameAware's {@code setBeanName}<br>
* 2. BeanClassLoaderAware's {@code setBeanClassLoader}<br>
* 3. BeanFactoryAware's {@code setBeanFactory}<br>
* 4. ResourceLoaderAware's {@code setResourceLoader}
* (only applicable when running in an application context)<br>
* 5. ApplicationEventPublisherAware's {@code setApplicationEventPublisher}
* (only applicable when running in an application context)<br>
* 6. MessageSourceAware's {@code setMessageSource}
* (only applicable when running in an application context)<br>
* 7. ApplicationContextAware's {@code setApplicationContext}
* (only applicable when running in an application context)<br>
* 8. ServletContextAware's {@code setServletContext}
* (only applicable when running in a web application context)<br>
* 9. {@code postProcessBeforeInitialization} methods of BeanPostProcessors<br>
* 10. InitializingBean's {@code afterPropertiesSet}<br>
* 11. a custom init-method definition<br>
* 12. {@code postProcessAfterInitialization} methods of BeanPostProcessors
*
* <p>On shutdown of a bean factory, the following lifecycle methods apply:<br>
* 1. DisposableBean's {@code destroy}<br>
* 2. a custom destroy-method definition
*
* 译:当一个bean工厂停止时,会调用下面的生命周期相关方法:
* 1. 销毁bean的方法(destroy)
* 2. 用户自定义的destory方法
*
* @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 class Test {
/**
* 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实例引