Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
woshizhushiqiu
spring-framework
提交
333e3272
S
spring-framework
项目概览
woshizhushiqiu
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
333e3272
编写于
9月 29, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revised javadoc for up-to-date constructor autowiring semantics
Issue: SPR-17299
上级
255015fc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
41 deletion
+43
-41
spring-beans/src/main/java/org/springframework/beans/factory/Aware.java
...rc/main/java/org/springframework/beans/factory/Aware.java
+10
-12
spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java
...g/springframework/beans/factory/annotation/Autowired.java
+13
-7
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
...tory/annotation/AutowiredAnnotationBeanPostProcessor.java
+20
-22
未找到文件。
spring-beans/src/main/java/org/springframework/beans/factory/Aware.java
浏览文件 @
333e3272
/*
* Copyright 2002-201
1
the original author or authors.
* Copyright 2002-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -17,21 +17,19 @@
package
org.springframework.beans.factory
;
/**
* Marker superinterface indicating that a bean is eligible to be
* notified by the Spring container of a particular framework object
* through a callback-style method. Actual method signature is
* determined by individual subinterfaces, but should typically
* consist of just one void-returning method that accepts a single
* argument.
* A marker superinterface indicating that a bean is eligible to be notified by the
* Spring container of a particular framework object through a callback-style method.
* The actual method signature is determined by individual subinterfaces but should
* typically consist of just one void-returning method that accepts a single argument.
*
* <p>Note that merely implementing {@link Aware} provides no default
*
functionality. Rather, processing must be done explicitly, for example
*
in a {@link org.springframework.beans.factory.config.BeanPostProcessor
BeanPostProcessor}.
* <p>Note that merely implementing {@link Aware} provides no default
functionality.
*
Rather, processing must be done explicitly, for example in a
*
{@link org.springframework.beans.factory.config.
BeanPostProcessor}.
* Refer to {@link org.springframework.context.support.ApplicationContextAwareProcessor}
* and {@link org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory}
* for examples of processing {@code *Aware} interface callbacks.
* for an example of processing specific {@code *Aware} interface callbacks.
*
* @author Chris Beams
* @author Juergen Hoeller
* @since 3.1
*/
public
interface
Aware
{
...
...
spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java
浏览文件 @
333e3272
...
...
@@ -23,15 +23,21 @@ import java.lang.annotation.RetentionPolicy;
import
java.lang.annotation.Target
;
/**
* Marks a constructor, field, setter method or config method as to be autowired
*
by
Spring's dependency injection facilities.
* Marks a constructor, field, setter method or config method as to be autowired
by
* Spring's dependency injection facilities.
*
* <p>Only one constructor (at max) of any given bean class may carry this annotation,
* indicating the constructor to autowire when used as a Spring bean. Such a
* constructor does not have to be public.
* <p>Only one constructor (at max) of any given bean class may declare this annotation
* with the 'required' parameter set to {@code true}, indicating <i>the</i> constructor
* to autowire when used as a Spring bean. If multiple <i>non-required</i> constructors
* declare the annotation, they will be considered as candidates for autowiring.
* The constructor with the greatest number of dependencies that can be satisfied by
* matching beans in the Spring container will be chosen. If none of the candidates
* can be satisfied, then a primary/default constructor (if present) will be used.
* If a class only declares a single constructor to begin with, it will always be used,
* even if not annotated. An annotated constructor does not have to be public.
*
* <p>Fields are injected right after construction of a bean, before any config
*
methods
are invoked. Such a config field does not have to be public.
* <p>Fields are injected right after construction of a bean, before any config
methods
* are invoked. Such a config field does not have to be public.
*
* <p>Config methods may have an arbitrary name and any number of arguments; each of
* those arguments will be autowired with a matching bean in the Spring container.
...
...
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
浏览文件 @
333e3272
...
...
@@ -74,15 +74,15 @@ import org.springframework.util.StringUtils;
* <p>Also supports JSR-330's {@link javax.inject.Inject @Inject} annotation,
* if available, as a direct alternative to Spring's own {@code @Autowired}.
*
* <p>Only one constructor (at max) of any given bean class may
carry this
*
annotation with the 'required' parameter set to {@code true},
*
indicating <i>the</i> constructor to autowire when used as a Spring bean.
*
If multiple <i>non-required</i> constructors carry the annotation, they
*
will be considered as candidates for autowiring. The constructor with
*
the greatest number of dependencies that can be satisfied by matching
*
beans in the Spring container will be chosen. If none of the candidates
*
can be satisfied, then a default constructor (if present) will be used.
* An annotated constructor does not have to be public.
* <p>Only one constructor (at max) of any given bean class may
declare this annotation
*
with the 'required' parameter set to {@code true}, indicating <i>the</i> constructor
*
to autowire when used as a Spring bean. If multiple <i>non-required</i> constructors
*
declare the annotation, they will be considered as candidates for autowiring.
*
The constructor with the greatest number of dependencies that can be satisfied by
*
matching beans in the Spring container will be chosen. If none of the candidates
*
can be satisfied, then a primary/default constructor (if present) will be used.
*
If a class only declares a single constructor to begin with, it will always be used,
*
even if not annotated.
An annotated constructor does not have to be public.
*
* <p>Fields are injected right after construction of a bean, before any
* config methods are invoked. Such a config field does not have to be public.
...
...
@@ -161,11 +161,11 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
/**
* Set the 'autowired' annotation type, to be used on constructors, fields,
* setter methods and arbitrary config methods.
* <p>The default autowired annotation type is the Spring-provided
*
{@link Autowired}
annotation, as well as {@link Value}.
* <p>The default autowired annotation type is the Spring-provided
{@link Autowired}
* annotation, as well as {@link Value}.
* <p>This setter property exists so that developers can provide their own
* (non-Spring-specific) annotation type to indicate that a member is
*
supposed
to be autowired.
* (non-Spring-specific) annotation type to indicate that a member is
supposed
* to be autowired.
*/
public
void
setAutowiredAnnotationType
(
Class
<?
extends
Annotation
>
autowiredAnnotationType
)
{
Assert
.
notNull
(
autowiredAnnotationType
,
"'autowiredAnnotationType' must not be null"
);
...
...
@@ -176,11 +176,11 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
/**
* Set the 'autowired' annotation types, to be used on constructors, fields,
* setter methods and arbitrary config methods.
* <p>The default autowired annotation type is the Spring-provided
*
{@link Autowired}
annotation, as well as {@link Value}.
* <p>The default autowired annotation type is the Spring-provided
{@link Autowired}
* annotation, as well as {@link Value}.
* <p>This setter property exists so that developers can provide their own
* (non-Spring-specific) annotation types to indicate that a member is
*
supposed
to be autowired.
* (non-Spring-specific) annotation types to indicate that a member is
supposed
* to be autowired.
*/
public
void
setAutowiredAnnotationTypes
(
Set
<
Class
<?
extends
Annotation
>>
autowiredAnnotationTypes
)
{
Assert
.
notEmpty
(
autowiredAnnotationTypes
,
"'autowiredAnnotationTypes' must not be empty"
);
...
...
@@ -189,8 +189,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
}
/**
* Set the name of a parameter of the annotation that specifies
* whether it is required.
* Set the name of a parameter of the annotation that specifies whether it is required.
* @see #setRequiredParameterValue(boolean)
*/
public
void
setRequiredParameterName
(
String
requiredParameterName
)
{
...
...
@@ -199,9 +198,8 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
/**
* Set the boolean value that marks a dependency as required
* <p>For example if using 'required=true' (the default),
* this value should be {@code true}; but if using
* 'optional=false', this value should be {@code false}.
* <p>For example if using 'required=true' (the default), this value should be
* {@code true}; but if using 'optional=false', this value should be {@code false}.
* @see #setRequiredParameterName(String)
*/
public
void
setRequiredParameterValue
(
boolean
requiredParameterValue
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录