上一节 1.2. Container Overview
目录
下一节 1.4. Dependencies
A Spring IoC container manages one or more beans. These beans are created with the configuration metadata that you supply to the container (for example, in the form of XML definitions).
Spring IoC容器管理一个或多个beans。这些bean由你提供给容器的配置元数据创建。
Within the container itself, these bean definitions are represented as BeanDefinition objects, which contain (among other information) the following metadata:
在容器体中,这些bean definitions表示为BeanDefinition对象,其中包含(除其他信息外)以下元数据:
* 带包路径的类名:特别,bean被定义的实际实现类。
* 描述bean在容器中如何表现的关于bean行为方面配置元素(scope,lifecycle callback等
* bean引用其他类的方法,这种引用也被称为写作者或者依赖。
* 用来创建一个新的对象的其他配置项,比如 数据池的大小,管理连接池的连接数量。
{WORD]
1.qualified
[B]
英 [ˈkwɒlɪfaɪd] 美 [ˈkwɑːlɪfaɪd]
adj.具备…的学历(或资历);具备…的知识(或技能);符合资格;有限度的;有保留的;有条件的
v.取得资格(或学历);合格;使合格;使具备资格;有权,使有权(做某事)
[W]
1a: fitted (as by training or experience) for a given purpose : COMPETENT
b: having complied with the specific requirements or precedent conditions (as for an office or employment) : ELIGIBLE
* 2: limited or modified in some way
// qualified approval【合格的批准】
This metadata translates to a set of properties that make up each bean definition. The following table describes these properties:
元数据转变为下面属性,这些属性组成了bean definition。下面是这些属性的描述:
Table 1. The bean definition
Property | Explained in… |
---|---|
Class | Instantiating Beans |
Name | Naming Beans |
Scope | Bean Scopes |
Constructor arguments | Dependency Injection |
Properties | Dependency Injection |
Autowiring mode | Autowiring Collaborators |
Lazy initialization mode | Lazy-initialized Beans |
Initialization method | Initialization Callbacks |
Destruction method | Destruction Callbacks |
In addition to bean definitions that contain information on how to create a specific bean, the ApplicationContext implementations also permit the registration of existing objects that are created outside the container (by users). This is done by accessing the ApplicationContext’s BeanFactory through the getBeanFactory() method, which returns the BeanFactory DefaultListableBeanFactory implementation. DefaultListableBeanFactory supports this registration through the registerSingleton(…) and registerBeanDefinition(…) methods. However, typical applications work solely with beans defined through regular bean definition metadata.
除了包含如何创建bean的信息的bean definitions外,ApplicationContext实现类也允许在容器外部注册现有对象的
创建(由用户)。这是通过访问ApplicationContext 的 BeanFactory的getBeanFactory() 方法完成,这个工厂方法
返回的是 DefaultListableBeanFactory 实现类。
DefaultListableBeanFactory 通过registerSingleton(..) and registerBeanDefinition(..) 两个方法来支持注册功能。
但是,典型的应用程序只是通过常规的bean definition元数据来定义bean。
[GRAMMAR]
1. the ApplicationContext implementations also permit the registration of existing objects that are created outside the container (by users)
主干:the ApplicationContext implementations also permit the registration
of existing 修饰 registration , that are 修饰 objects
Bean metadata and manually supplied singleton instances need to be registered as early as possible, in order for the container to properly reason about them during autowiring and other introspection steps. While overriding existing metadata and existing singleton instances is supported to some degree, the registration of new beans at runtime (concurrently with live access to the factory) is not officially supported and may lead to concurrent access exceptions, inconsistent state in the bean container, or both.
应该尽早地注册bean元数据和手动创建singleton实例,这是为了在autowiring和其他作业中 容器可以正确完成 。
尽管重载已存在的元数据和singleton实例在某种程度上可以被支持,但是在运行时注册新的bean(并发访问工厂类)
不被官方支持,并可能导致并行存取异常或者bean容器的状态不一致性。
1.3.1. bean的命名
Every bean has one or more identifiers. These identifiers must be unique within the container that hosts the bean. A bean usually has only one identifier. However, if it requires more than one, the extra ones can be considered aliases.
每一个bean都有一个或者多个唯一标识。这些标识必须在收纳bean的容器中唯一。通常来说,bean只有一个标识。
但是如果它需要多余一个标识,其他的标识可以被称为aliases(别称)。
In XML-based configuration metadata, you use the id attribute, the name attribute, or both to specify the bean identifiers. The id attribute lets you specify exactly one id. Conventionally, these names are alphanumeric (‘myBean’, ‘someService’, etc.), but they can contain special characters as well. If you want to introduce other aliases for the bean, you can also specify them in the name attribute, separated by a comma (,), semicolon (, or white space. As a historical note, in versions prior to Spring 3.1, the id attribute was defined as an xsd:ID type, which constrained possible characters. As of 3.1, it is defined as an xsd:string type. Note that bean id uniqueness is still enforced by the container, though no longer by XML parsers.
在基于XML的配置元数据中,你可以使用 id或者name来作为bean的标识。id属性支持您标记一个确切的id。
按照惯例,这些名称可以是字母和数字的组合 (比如 'myBean', 'someService'), 同时name也可以包含特殊字符。
如果你想为bean设置aliases,你可以在 name属性上 通过 逗号,分号或者 空格来区分。在历史版本中,Spring3.1
以前id属性被定义为 xsd:ID 样式,在3.1版本,它被定义为 xsd:string 。请注意,bean ID唯一性仍然由容器强制执行,尽管不再由XML解析器执行。
You are not required to supply a name or an id for a bean. If you do not supply a name or id explicitly, the container generates a unique name for that bean. However, if you want to refer to that bean by name, through the use of the ref element or a Service Locator style lookup, you must provide a name. Motivations for not supplying a name are related to using inner beans and autowiring collaborators.
bean的id和name并不是必须输入的项目。如果你没有明确提供一个name或者id,容器会自动为bean生成唯一name。
但如果你想要通过name引用bean(通过使用ref或者 Service Locator style lookup),那么你必须要指定name。
这种情况就类似使用内部类或者autowiring协作类。
The convention is to use the standard Java convention for instance field names when naming beans. That is, bean names start with a lowercase letter and are camel-cased from there. Examples of such names include accountManager, accountService, userDao, loginController, and so forth.
Naming beans consistently makes your configuration easier to read and understand. Also, if you use Spring AOP, it helps a lot when applying advice to a set of beans related by name.
bean命名惯例
bean命名的惯例使用标准的Java对象field的规则。也就是,bean name一小写字母开头并采用camel-cased样式。
这种命名规则包括accountManager, accountService, userDao, loginController等。一贯地使用这种方式为bean
命名,能够让您的配置更加容易阅读和理解。同时如果你使用Spring AOP,这种命名方式对于通过name添加advice
到一批bean很有帮助。
With component scanning in the classpath, Spring generates bean names for unnamed components, following the rules described earlier: essentially, taking the simple class name and turning its initial character to lower-case. However, in the (unusual) special case when there is more than one character and both the first and second characters are upper case, the original casing gets preserved. These are the same rules as defined by java.beans.Introspector.decapitalize (which Spring uses here).
在class路径component scanning注册bean的过程中,Spring为没有设置name的组件按照下面的规则生成
bean name:获取class名称,然后把首字母改为小写。但是,在一些特殊情况下,如果有多于一个字符,前两个
都是大写字母,首字母就被保留下来了。这个规则在java.beans.Introspector.decapitalize中被定义(这也是
Spring使用的类)
In a bean definition itself, you can supply more than one name for the bean, by using a combination of up to one name specified by the id attribute and any number of other names in the name attribute. These names can be equivalent aliases to the same bean and are useful for some situations, such as letting each component in an application refer to a common dependency by using a bean name that is specific to that component itself.
在Bean Definition之外添加bean别称
在bean definition 中,通过为id属性提供一个名称,为name属性提供多个其他名称的方式,你能够为bean设置
多于一个的name。这些name与同一个bean的别称aliase一样,在不同场景下很有用处,比如我们可以让一个
应用程序下的每一个组件使用它自己专属的bean name 引用同一个依赖关系。
Specifying all aliases where the bean is actually defined is not always adequate, however. It is sometimes desirable to introduce an alias for a bean that is defined elsewhere. This is commonly the case in large systems where configuration is split amongst each subsystem, with each subsystem having its own set of object definitions. In XML-based configuration metadata, you can use the element to accomplish this. The following example shows how to do so:
但是,只在bean实际被定义的地方指定所有别名是不够的。 有时需要为别处引入定义bean别名。通常都有这种
情况,在大型系统中,配置被划分在每个子系统之间,每个子系统都有自己的对象定义集。在基于XML的配置
元数据中,你可以使用 来完成这个。下面
1. adequate
英 [ˈædɪkwət] 美 [ˈædɪkwət]
adj.足够的;合格的;合乎需要的
<alias name="fromName" alias="toName"/>
In this case, a bean (in the same container) named fromName may also, after the use of this alias definition, be referred to as toName.
在这个例子中,在同一个容器中的bean命名为 fromName,在使用了alias定义后,也可以使用名称toName。
For example, the configuration metadata for subsystem A may refer to a DataSource by the name of subsystemA-dataSource. The configuration metadata for subsystem B may refer to a DataSource by the name of subsystemB-dataSource. When composing the main application that uses both these subsystems, the main application refers to the DataSource by the name of myApp-dataSource. To have all three names refer to the same object, you can add the following alias definitions to the configuration metadata:
在下面的这个例子中,子系统A的配置元数据可以通过名称subsystemA-dataSource引用数据源。
子系统B的配置元数据可以通过名称subsystemB-dataSource引用数据源。
当我们使用这两个子系统组成主应用程序,主应用程序通过名称myApp-dataSource引用数据源。
为了让这三个名称引用同一个对象,你可以增加下面的alias定义来配置元数据。
<alias name="myApp-dataSource" alias="subsystemA-dataSource"/>
<alias name="myApp-dataSource" alias="subsystemB-dataSource"/>
Now each component and the main application can refer to the dataSource through a name that is unique and guaranteed not to clash with any other definition (effectively creating a namespace), yet they refer to the same bean.
现在每一个组件和主应用程序可以通过唯一的名称引用数据源,并且保证不会与其他定义冲突(有效地创建一个命名空间),
但是他们引用的是同一个bean。
[WORD]
1. guaranteed
英 [ˌɡærənˈtiːd] 美 [ˌɡærənˈtiːd]
adj.必然的;确定会发生的
v.保证;担保;保障;提供(产品)保修单(免费掉换或修理有问题的产品);使必然发生;确保
guarantee的过去分词和过去式
If you use Javaconfiguration, the @Bean annotation can be used to provide aliases. See Using the @Bean Annotation for details.
Java代码配置方式
如果你使用Java代码配置方式,@Bean标签能够被用来提供别称。参考@Bean标签了解更多详情。
A bean definition is essentially a recipe for creating one or more objects. The container looks at the recipe for a named bean when asked and uses the configuration metadata encapsulated by that bean definition to create (or acquire) an actual object.
bean definition本质上来说是一个创建一个活多个对象的方法。
当被要求的时候,容器查看命名bean的方法,并使用封装了bean definition
的配置元数据去创建(或者获取)一个实际的对象。
[WORD]
1. essentially
英 [ɪˈsenʃəli] 美 [ɪˈsenʃəli]
adv.本质上;根本上;基本上
2. recipe
英 [ˈresəpi] 美 [ˈresəpi]
n.烹饪法;食谱;方法;秘诀;诀窍
3. encapsulated
英 [ɪnˈkæpsjuleɪtɪd] 美 [ɪnˈkæpsjuleɪtɪd]
v.简述;概括;压缩
[GRAMMAR]
The container looks at the recipe for a named bean when asked and uses the configuration metadata encapsulated by that bean definition to create (or acquire) an actual object
主干:The container looks at ... and uses ...
for a ... 修饰 recipe,when asked 的主语是 con'tanencapsulated by ... 修饰metadata
If you use XML-based configuration metadata, you specify the type (or class) of object that is to be instantiated in the class attribute of the element. This class attribute (which, internally, is a Class property on a BeanDefinition instance) is usually mandatory. (For exceptions, see Instantiation by Using an Instance Factory Method and Bean Definition Inheritance.) You can use the Class property in one of two ways:
如果你使用的是基于XML的配置元数据,你在 元素的class 属性上描述这个对象类型(或者class)。
此类属性(在内部是BeanDefinition实例的Class属性)通常是必需的。
(关于异常,请参见使用实例工厂方法实例化和 Bean Definition的继承。)
你可以通过下面两种方法的一种来使用Class属性:
[WORD]
1. specify
[B]
英 [ˈspesɪfaɪ] 美 [ˈspesɪfaɪ]
v.具体说明;明确规定;详述;详列
[W]
1: to name or state explicitly or in detail
2: to include as an item in a specification
----
2. mandatory
[B]
英 [ˈmændətəri] 美 [ˈmændətɔːri]
adj.强制的;法定的;义务的
n.受托者
[W]
1: required by a law or rule : OBLIGATORY
the mandatory retirement age
2: of, by, relating to, or holding a League of Nations mandate
通常,在容器中通过反射调用其构造函数直接创建Bean,描述要构造的Bean类,
在某种程度上,这等同于使用new运算符的Java代码。
描述包含要创建对象的静态工厂方法的实际类,在少数情况下,容器将在类上调用静态工厂方法以创建Bean。
从静态工厂方法调用返回的对象类型可以是同一个class,也可以是完全不同的另一个class。
Inner class names
If you want to configure a bean definition for a static nested class, you have to use the binary name of the nested class.
内部类名称
如果要为静态嵌套的class配置bean definition定义,则必须使用嵌套class的二进制名称。
nested
英 [ˈnestɪd] 美 [ˈnestɪd]
v.筑巢;巢居;嵌套(信息)
For example, if you have a class called SomeThing in the com.example package, and this SomeThing class has a static nested class called OtherThing, the value of the class attribute on a bean definition would be com.example.SomeThing$OtherThing.
比如,如果你在com.example包下,有一个class名称为SomeThing,
并且这个SomeThing 类有一个静态嵌套类叫做 OtherThing,
在bean definition 里面 class属性的值为 com.example.SomeThing$OtherThing。
Notice the use of the $ character in the name to separate the nested class name from the outer class name.
请注意,名称中使用$字符将嵌套类名称与外部类名称分开。
When you create a bean by the constructor approach, all normal classes are usable by and compatible with Spring. That is, the class being developed does not need to implement any specific interfaces or to be coded in a specific fashion. Simply specifying the bean class should suffice. However, depending on what type of IoC you use for that specific bean, you may need a default (empty) constructor.
通过构造方法实例化
通过构造方法创建bean时,所有普通类都可以被Spring使用并与之兼容.
也就是说,正在开发的类不需要实现任何特定的接口或以特定的方式进行编码。
只需指定bean类就足够了。
但是,取决于您用于支持特定Bean的IoC的类型,您可能需要一个默认(空)构造函数
[WORD]
1.approach
[B]
英 [əˈprəʊtʃ] 美 [əˈproʊtʃ]
v.(在距离或时间上)靠近,接近;接洽;建议;要求;(在数额、水平或质量上)接近
n.(待人接物或思考问题的)方式,方法,态度;(距离和时间上的)靠近,接近;接洽;建议;要求
[W]
1a: to draw closer to : NEAR
// approach a destination
b: to come very near to : to be almost the same as
// … its mathematics approaches mysticism.
— Theodore Sturgeon
// as the quantity x approaches zero
2
a: to make advances to especially in order to create a desired result
// was approached by several Broadway producers
b: to take preliminary steps toward accomplishment or full knowledge or experience of
// Try to approach the subject with an open mind.
The Spring IoC container can manage virtually any class you want it to manage. It is not limited to managing true JavaBeans. Most Spring users prefer actual JavaBeans with only a default (no-argument) constructor and appropriate setters and getters modeled after the properties in the container. You can also have more exotic non-bean-style classes in your container. If, for example, you need to use a legacy connection pool that absolutely does not adhere to the JavaBean specification, Spring can manage it as well.
Spring IoC容器几乎可以管理任何你想管理的类。它不限于管理真正的JavaBeans。大多数Spring用户更喜欢使用实际的JavaBean,
它们仅具有默认(无参数)构造函数,并具有根据容器中的属性建模的适当的setter和getters方法。在容器中,您还可以使用更多
奇特的非bean样式的类。 例如,如果您需要使用绝对不符合JavaBean规范的老式连接池,则Spring也可以对其进行管理。
1. virtually
[B]
英 [ˈvɜːtʃuəli] 美 [ˈvɜːrtʃuəli]
adv.几乎;差不多;事实上;实际上;模拟;虚拟;以模拟现实技术
[W]
1: almost entirely : NEARLY
2: for all practical purposes
// virtually unknown
----
2. exotic
[B]
英 [ɪɡˈzɒtɪk] 美 [ɪɡˈzɑːtɪk]
adj.来自异国(尤指热带国家)的;奇异的;异国情调的;异国风味的
[W]
1: introduced from another country : not native to the place where found
// exotic plants【外来植物】
2 archaic : FOREIGN, ALIEN【古语:外国的、外星人的(古代也有外星人?)】
3: strikingly, excitingly, or mysteriously different or unusual
// exotic flavors【异国风味】
4: of or relating to striptease
// exotic dancing
----
3. legacy
[B]
英 [ˈleɡəsi] 美 [ˈleɡəsi]
n.遗产;遗赠财物;遗留;后遗症
[W]
1: a gift by will especially of money or other personal property : BEQUEST
// She left us a legacy of a million dollars.
* 2: something transmitted by or received from an ancestor or predecessor or from the past
// the legacy of the ancient philosophers
// The war left a legacy of pain and suffering.
3: a candidate for membership in an organization (such as a school or fraternal order) who is given special status because of a familial relationship to a member
// Legacies, or children of alumni, are three times more likely to be accepted to Harvard than other high school graduates with the same (sometimes better) scores …— Michael Lind
----
4. adhere
[B]
英 [ədˈhɪə(r)] 美 [ədˈhɪr]
v.黏附;附着
[W]
1: to hold fast or stick by or as if by gluing, suction, grasping, or fusing
// The stamp failed to adhere to the envelope.
2: to give support or maintain loyalty
// adhere to traditional values【坚持传统价值观】
3: to bind oneself to observance
// adhere to the rules【遵守规则】
4 obsolete : ACCORD sense intransitive 1
With XML-based configuration metadata you can specify your bean class as follows:
使用基于XML的配置元数据,您可以如下指定bean类:
<bean id="exampleBean" class="examples.ExampleBean"/>
<bean name="anotherExample" class="examples.ExampleBeanTwo"/>
For details about the mechanism for supplying arguments to the constructor (if required) and setting object instance properties after the object is constructed, see Injecting Dependencies.
关于向构造方法提供参数(如果需要)、在构造对象之后设置对象实例属性的机制的详细信息,请参见注入依赖。
When defining a bean that you create with a static factory method, use the class attribute to specify the class that contains the static factory method and an attribute named factory-method to specify the name of the factory method itself. You should be able to call this method (with optional arguments, as described later) and return a live object, which subsequently is treated as if it had been created through a constructor. One use for such a bean definition is to call static factories in legacy code.
使用静态工厂方法实例化
当你使用静态工厂方法创建bean时,请使用class属性指定包含静态工厂方法的类,并使用名为factory-method的属性指定工厂方法
本身的名称。您应该能够调用此方法(带有可选参数,如后面所述),并返回一个活动对象,该对象随后将被视为已通过构造函数
创建。 这种bean definition的一种用法是在旧版代码中调用静态工厂。
The following bean definition specifies that the bean be created by calling a factory method. The definition does not specify the type (class) of the returned object, only the class containing the factory method. In this example, the createInstance() method must be a static method. The following example shows how to specify a factory method:
下面的bean definition描述了被工厂方法创建的bean。该定义不指定返回对象的类型(类),而仅指定包含工厂方法的类。
在这个例子中,createInstance() 方法必须是一个静态方法。下面的例子演示如何创建一个工厂方法。
<bean id="clientService"
class="examples.ClientService"
factory-method="createInstance"/>
The following example shows a class that would work with the preceding bean definition:
下面的例子演示一个类如何与前面的bean definition协作。
public class ClientService {
private static ClientService clientService = new ClientService();
private ClientService() {}
public static ClientService createInstance() {
return clientService;
}
}
For details about the mechanism for supplying (optional) arguments to the factory method and setting object instance properties after the object is returned from the factory, see Dependencies and Configuration in Detail.
关于工厂方法提供(可选)参数并在从工厂返回对象后设置对象实例属性的机制的详细信息,请参见依赖 和 配置 章节获得详情。
Similar to instantiation through a static factory method, instantiation with an instance factory method invokes a non-static method of an existing bean from the container to create a new bean. To use this mechanism, leave the class attribute empty and, in the factory-bean attribute, specify the name of a bean in the current (or parent or ancestor) container that contains the instance method that is to be invoked to create the object. Set the name of the factory method itself with the factory-method attribute. The following example shows how to configure such a bean:
使用实例工厂方法实例化
类似于通过静态工厂方法进行实例化,使用实例工厂方法进行实例化会从容器中调用现有bean的非静态方法来创建新bean。
要使用这种机制,请将class属性留空,并在factory-bean属性中,在包含要创建该对象的实例方法的当前(或父或祖先)容器中
指定bean的名称。使用factory-method属性设置工厂方法本身的名称。以下例子演示了如何配置此类Bean:
<bean id="serviceLocator" class="examples.DefaultServiceLocator">
bean>
<bean id="clientService"
factory-bean="serviceLocator"
factory-method="createClientServiceInstance"/>
The following example shows the corresponding class:
下面的例子演示了相关的类:
public class DefaultServiceLocator {
private static ClientService clientService = new ClientServiceImpl();
public ClientService createClientServiceInstance() {
return clientService;
}
}
One factory class can also hold more than one factory method, as the following example shows:
一个工厂类可以包含多于一个的工厂方法,就像下面例子演示的:
<bean id="serviceLocator" class="examples.DefaultServiceLocator">
bean>
<bean id="clientService"
factory-bean="serviceLocator"
factory-method="createClientServiceInstance"/>
<bean id="accountService"
factory-bean="serviceLocator"
factory-method="createAccountServiceInstance"/>
The following example shows the corresponding class:
下面的例子演示了相关的类:
public class DefaultServiceLocator {
private static ClientService clientService = new ClientServiceImpl();
private static AccountService accountService = new AccountServiceImpl();
public ClientService createClientServiceInstance() {
return clientService;
}
public AccountService createAccountServiceInstance() {
return accountService;
}
}
This approach shows that the factory bean itself can be managed and configured through dependency injection (DI). See Dependencies and Configuration in Detail.
这种方法表明,工厂Bean本身可以通过依赖项注入(DI)进行管理和配置。 详细信息,请参见依赖和配置章节。
In Spring documentation, “factory bean” refers to a bean that is configured in the Spring container and that creates objects through an instance or static factory method. By contrast, FactoryBean (notice the capitalization) refers to a Spring-specific FactoryBean implementation class.
在Spring文档里面,“factory bean”指的是配置在Spring容器里面的一个bean,它通过实例或者静态工厂方法创建。
与之相比,FactoryBean(请注意大小写)指的是特定于Spring的FactoryBean实现类。
The runtime type of a specific bean is non-trivial to determine. A specified class in the bean metadata definition is just an initial class reference, potentially combined with a declared factory method or being a FactoryBean class which may lead to a different runtime type of the bean, or not being set at all in case of an instance-level factory method (which is resolved via the specified factory-bean name instead). Additionally, AOP proxying may wrap a bean instance with an interface-based proxy with limited exposure of the target bean’s actual type (just its implemented interfaces).
确定Bean的运行时类型
确定特定bean的运行时类型非常有意义。 在Bean元数据定义中的指定类只是初始的类引用,
与声明的工厂方法潜在地结合使用,或者如果本身是FactoryBean类,可能产生不同类型的Bean运行时,
或者在实例化层的工厂方法上完全不进行设置 (另外,通过特别的factory-bean名称来进行设置)。
此外,AOP代理可以使用基于接口的代理包装Bean实例,而目标Bean的实际类型(仅是其实现的接口)的暴露程度有限。
(第二句话总感觉很别扭,没有理解什么意思)
[WORD]
1. non-trivial
英 [ˈnəʊn ˈtrɪviəl] 美 [ˈnoʊn ˈtrɪviəl]
非平凡;非平凡的;不平凡;有意义的;面对较重大
[W]
1: not trivial : SIGNIFICANT, IMPORTANT【非凡、重要】
// a small but nontrivial amount
// … engineering a power plant around the technology is a nontrivial problem.
【围绕该技术设计电厂是一个不平凡的问题。】
— John Fleck
2 mathematics : having the value of at least one variable or term not equal to zero
【数学:具有至少一个不等于零的变量或项的值】
// a nontrivial solution
----
2. potentially
[B]
英 [pə'tenʃəli] 美 [pə'tenʃəli]
adv.潜在地
[W]
: in a potential or possible state or condition —used to describe the possible results or effects of something
// a potentially dangerous situation 【潜在危险情况】
[=a situation that has the potential to be or become dangerous]
// a potentially useful feature【潜在有用的功能】
The recommended way to find out about the actual runtime type of a particular bean is a BeanFactory.getType call for the specified bean name. This takes all of the above cases into account and returns the type of object that a BeanFactory.getBean call is going to return for the same bean name.
找出特定bean的实际运行时类型的推荐方法是通过 BeanFactory.getType方法来调用指定的bean name。
这考虑了以上所有情况,而且 它返回的对象的类型,与BeanFactory.getBean方法返回的是同一个bean name。