Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
3185f67b
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
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 搜索 >>
提交
3185f67b
编写于
8月 12, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid stack overflow in case of chained factory-bean references to FactoryBean class
Issue: SPR-14551
上级
9520a593
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
26 deletion
+28
-26
spring-beans/src/main/java/org/springframework/beans/factory/BeanFactory.java
...n/java/org/springframework/beans/factory/BeanFactory.java
+6
-4
spring-beans/src/main/java/org/springframework/beans/factory/NamedBean.java
...ain/java/org/springframework/beans/factory/NamedBean.java
+5
-5
spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java
...work/beans/factory/config/AutowireCapableBeanFactory.java
+4
-4
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
...s/factory/support/AbstractAutowireCapableBeanFactory.java
+13
-13
未找到文件。
spring-beans/src/main/java/org/springframework/beans/factory/BeanFactory.java
浏览文件 @
3185f67b
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -114,6 +114,7 @@ public interface BeanFactory {
*/
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
...
...
@@ -151,15 +152,16 @@ public interface BeanFactory {
/**
* Return the bean instance that uniquely matches the given object type, if any.
* @param requiredType type the bean must match; can be an interface or superclass.
* {@code null} is disallowed.
* <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.
* {@code null} is disallowed.
* @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
*/
...
...
@@ -170,7 +172,7 @@ public interface BeanFactory {
* <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
if
creating a prototype using explicit arguments
* @param args arguments to use
when
creating a prototype using explicit arguments
* @return an instance of the bean
* @throws NoSuchBeanDefinitionException if there is no such bean definition
* @throws BeanDefinitionStoreException if arguments have been given but
...
...
spring-beans/src/main/java/org/springframework/beans/factory/NamedBean.java
浏览文件 @
3185f67b
/*
* Copyright 2002-20
0
6 the original author or authors.
* Copyright 2002-20
1
6 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,10 +17,10 @@
package
org.springframework.beans.factory
;
/**
* Counterpart of
BeanNameAware
. Returns the bean name of an object.
* Counterpart of
{@link BeanNameAware}
. Returns the bean name of an object.
*
* <p>This interface can be introduced to avoid a brittle dependence
*
on
bean name in objects used with Spring IoC and Spring AOP.
* <p>This interface can be introduced to avoid a brittle dependence
on
* bean name in objects used with Spring IoC and Spring AOP.
*
* @author Rod Johnson
* @since 2.0
...
...
@@ -29,7 +29,7 @@ package org.springframework.beans.factory;
public
interface
NamedBean
{
/**
* Return the name of this bean in a Spring bean factory.
* Return the name of this bean in a Spring bean factory
, if known
.
*/
String
getBeanName
();
...
...
spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java
浏览文件 @
3185f67b
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -114,9 +114,9 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
* <p>Performs full initialization of the bean, including all applicable
* {@link BeanPostProcessor BeanPostProcessors}.
* <p>Note: This is intended for creating a fresh instance, populating annotated
* fields and methods as well as applying all standard bean initialiation callbacks.
* fields and methods as well as applying all standard bean initiali
z
ation callbacks.
* It does <i>not</> imply traditional by-name or by-type autowiring of properties;
* use {@link #createBean(Class, int, boolean)} for th
at
purposes.
* use {@link #createBean(Class, int, boolean)} for th
ose
purposes.
* @param beanClass the class of the bean to create
* @return the new bean instance
* @throws BeansException if instantiation or wiring failed
...
...
@@ -129,7 +129,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
* <p>Note: This is essentially intended for (re-)populating annotated fields and
* methods, either for new instances or for deserialized instances. It does
* <i>not</i> imply traditional by-name or by-type autowiring of properties;
* use {@link #autowireBeanProperties} for th
at
purposes.
* use {@link #autowireBeanProperties} for th
ose
purposes.
* @param existingBean the existing bean instance
* @throws BeansException if wiring failed
*/
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
浏览文件 @
3185f67b
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -425,9 +425,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #doCreateBean
*/
@Override
protected
Object
createBean
(
final
String
beanName
,
final
RootBeanDefinition
mbd
,
final
Object
[]
args
)
throws
BeanCreationException
{
protected
Object
createBean
(
String
beanName
,
RootBeanDefinition
mbd
,
Object
[]
args
)
throws
BeanCreationException
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Creating instance of bean '"
+
beanName
+
"'"
);
}
...
...
@@ -596,7 +594,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
/**
* Determine the
bean
type for the given bean definition which is based on
* Determine the
target
type for the given bean definition which is based on
* a factory method. Only called if there is no singleton instance registered
* for the target bean already.
* <p>This implementation determines the type matching {@link #createBean}'s
...
...
@@ -606,7 +604,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @param mbd the merged bean definition for the bean
* @param typesToMatch the types to match in case of internal type matching purposes
* (also signals that the returned {@code Class} will never be exposed to application code)
* @return the type for the bean if determinable, or {@code null}
el
se
* @return the type for the bean if determinable, or {@code null}
otherwi
se
* @see #createBean
*/
protected
Class
<?>
getTypeForFactoryMethod
(
String
beanName
,
RootBeanDefinition
mbd
,
Class
[]
typesToMatch
)
{
...
...
@@ -745,10 +743,14 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
if
(
objectType
.
value
!=
null
)
{
return
objectType
.
value
;
}
else
{
// No type found for shortcut FactoryBean instance:
// fall back to full creation of the FactoryBean instance.
return
super
.
getTypeForFactoryBean
(
beanName
,
mbd
);
}
}
// No type found - fall back to full creation of the FactoryBean instance.
return
super
.
getTypeForFactoryBean
(
beanName
,
mbd
);
return
null
;
}
/**
...
...
@@ -767,7 +769,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
SmartInstantiationAwareBeanPostProcessor
ibp
=
(
SmartInstantiationAwareBeanPostProcessor
)
bp
;
exposedObject
=
ibp
.
getEarlyBeanReference
(
exposedObject
,
beanName
);
if
(
exposedObject
==
null
)
{
return
exposedObject
;
return
null
;
}
}
}
...
...
@@ -782,8 +784,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
/**
* Obtain a "shortcut" singleton FactoryBean instance to use for a
* {@code getObjectType()} call, without full initialization
* of the FactoryBean.
* {@code getObjectType()} call, without full initialization of the FactoryBean.
* @param beanName the name of the bean
* @param mbd the bean definition for the bean
* @return the FactoryBean instance, or {@code null} to indicate
...
...
@@ -824,8 +825,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
/**
* Obtain a "shortcut" non-singleton FactoryBean instance to use for a
* {@code getObjectType()} call, without full initialization
* of the FactoryBean.
* {@code getObjectType()} call, without full initialization of the FactoryBean.
* @param beanName the name of the bean
* @param mbd the bean definition for the bean
* @return the FactoryBean instance, or {@code null} to indicate
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录