Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
希川
container-mini
提交
a9925f1b
C
container-mini
项目概览
希川
/
container-mini
通知
6
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
container-mini
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a9925f1b
编写于
11月 18, 2021
作者:
希川
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<feat>: 循环依赖问题 - 改用jdk代理,如要使用cglib代理的话,得解决“代理的代理”的问题
上级
0b2c279b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
33 deletion
+29
-33
src/main/java/cn/noexception/container/aop/TargetSource.java
src/main/java/cn/noexception/container/aop/TargetSource.java
+9
-4
src/main/java/cn/noexception/container/aop/framework/Cglib2AopProxy.java
...n/noexception/container/aop/framework/Cglib2AopProxy.java
+1
-1
src/main/java/cn/noexception/container/factory/config/BeanDefinition.java
.../noexception/container/factory/config/BeanDefinition.java
+16
-27
src/main/java/cn/noexception/container/factory/support/AbstractAutowiredCapableBeanFactory.java
.../factory/support/AbstractAutowiredCapableBeanFactory.java
+3
-1
未找到文件。
src/main/java/cn/noexception/container/aop/TargetSource.java
浏览文件 @
a9925f1b
package
cn.noexception.container.aop
;
import
cn.noexception.container.factory.utils.ClassUtils
;
/**
* TargetSource
*
...
...
@@ -10,15 +12,18 @@ public class TargetSource {
private
final
Object
target
;
public
TargetSource
(
Object
target
){
public
TargetSource
(
Object
target
)
{
this
.
target
=
target
;
}
public
Class
<?>[]
getTargetClass
(){
return
this
.
target
.
getClass
().
getInterfaces
();
public
Class
<?>[]
getTargetClass
()
{
Class
<?>
clazz
=
this
.
target
.
getClass
();
// 如果是 cglib 代理的话,得获取 superClass 才可以
clazz
=
ClassUtils
.
isCglibProxyClass
(
clazz
)
?
clazz
.
getSuperclass
()
:
clazz
;
return
clazz
.
getInterfaces
();
}
public
Object
getTarget
(){
public
Object
getTarget
()
{
return
this
.
target
;
}
...
...
src/main/java/cn/noexception/container/aop/framework/Cglib2AopProxy.java
浏览文件 @
a9925f1b
...
...
@@ -35,7 +35,7 @@ public class Cglib2AopProxy implements AopProxy {
private
final
AdvisedSupport
advised
;
p
rivate
DynamicAdvisedInterceptor
(
AdvisedSupport
advised
)
{
p
ublic
DynamicAdvisedInterceptor
(
AdvisedSupport
advised
)
{
this
.
advised
=
advised
;
}
...
...
src/main/java/cn/noexception/container/factory/config/BeanDefinition.java
浏览文件 @
a9925f1b
...
...
@@ -22,8 +22,7 @@ public class BeanDefinition {
private
boolean
prototype
=
false
;
public
BeanDefinition
(
Class
beanClass
)
{
this
.
beanClass
=
beanClass
;
this
.
propertyValues
=
new
PropertyValues
();
this
(
beanClass
,
null
);
}
public
BeanDefinition
(
Class
beanClass
,
PropertyValues
propertyValues
)
{
...
...
@@ -31,6 +30,21 @@ public class BeanDefinition {
this
.
propertyValues
=
propertyValues
!=
null
?
propertyValues
:
new
PropertyValues
();
}
public
void
setScope
(
String
scope
)
{
this
.
scope
=
scope
;
this
.
singleton
=
SCOPE_SINGLETON
.
equals
(
scope
);
this
.
prototype
=
SCOPE_PROTOTYPE
.
equals
(
scope
);
}
public
boolean
isSingleton
()
{
return
singleton
;
}
public
boolean
isPrototype
()
{
return
prototype
;
}
public
Class
getBeanClass
()
{
return
beanClass
;
}
...
...
@@ -63,29 +77,4 @@ public class BeanDefinition {
this
.
destroyMethodName
=
destroyMethodName
;
}
public
String
getScope
()
{
return
scope
;
}
public
void
setScope
(
String
scope
)
{
this
.
scope
=
scope
;
this
.
singleton
=
SCOPE_SINGLETON
.
equals
(
scope
);
this
.
prototype
=
SCOPE_PROTOTYPE
.
equals
(
scope
);
}
public
boolean
isSingleton
()
{
return
singleton
;
}
public
void
setSingleton
(
boolean
singleton
)
{
this
.
singleton
=
singleton
;
}
public
boolean
isPrototype
()
{
return
prototype
;
}
public
void
setPrototype
(
boolean
prototype
)
{
this
.
prototype
=
prototype
;
}
}
src/main/java/cn/noexception/container/factory/support/AbstractAutowiredCapableBeanFactory.java
浏览文件 @
a9925f1b
...
...
@@ -19,7 +19,9 @@ import java.lang.reflect.Method;
*/
public
abstract
class
AbstractAutowiredCapableBeanFactory
extends
AbstractBeanFactory
implements
AutowireCapableBeanFactory
{
private
InstantiationStrategy
instantiationStrategy
=
new
CglibSubclassingInstantiationStrategy
();
// 暂时默认选择 cglib 来实例化
// 实例化策略
// private InstantiationStrategy instantiationStrategy = new CglibSubclassingInstantiationStrategy(); // 选择使用 cglib代理来实例化
private
InstantiationStrategy
instantiationStrategy
=
new
SimpleInstantiationStrategy
();
// 选择使用 JDK代理 来实例化
protected
Object
doCreateBean
(
String
beanName
,
BeanDefinition
beanDefinition
,
Object
[]
args
)
{
Object
bean
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录