Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
97cea7f3
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 搜索 >>
提交
97cea7f3
编写于
9月 13, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BeanDefinition interface exposes initMethodName and destroyMethodName
Also includes setters for role and description. Issue: SPR-17275
上级
77887ef7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
35 deletion
+76
-35
spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java
.../springframework/beans/factory/config/BeanDefinition.java
+56
-13
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java
...amework/beans/factory/support/AbstractBeanDefinition.java
+6
-0
spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java
...ngframework/context/annotation/AnnotationConfigUtils.java
+7
-11
spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java
...amework/scripting/support/ScriptFactoryPostProcessor.java
+7
-11
未找到文件。
spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java
浏览文件 @
97cea7f3
/*
* Copyright 2002-201
7
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.
...
...
@@ -242,28 +242,42 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
return
!
getPropertyValues
().
isEmpty
();
}
/**
* Set the name of the initializer method.
* @since 5.1
*/
void
setInitMethodName
(
@Nullable
String
initMethodName
);
// Read-only attributes
/**
* Return the name of the initializer method.
* @since 5.1
*/
@Nullable
String
getInitMethodName
();
/**
* Return whether this a <b>Singleton</b>, with a single, shared instance
* returned on all calls.
* @see #SCOPE_SINGLETON
* Set the name of the destroy method.
* @since 5.1
*/
boolean
isSingleton
(
);
void
setDestroyMethodName
(
@Nullable
String
destroyMethodName
);
/**
* Return whether this a <b>Prototype</b>, with an independent instance
* returned for each call.
* @since 3.0
* @see #SCOPE_PROTOTYPE
* Return the name of the destroy method.
* @since 5.1
*/
boolean
isPrototype
();
@Nullable
String
getDestroyMethodName
();
/**
* Return whether this bean is "abstract", that is, not meant to be instantiated.
* Set the role hint for this {@code BeanDefinition}. The role hint
* provides the frameworks as well as tools with an indication of
* the role and importance of a particular {@code BeanDefinition}.
* @since 5.1
* @see #ROLE_APPLICATION
* @see #ROLE_SUPPORT
* @see #ROLE_INFRASTRUCTURE
*/
boolean
isAbstract
(
);
void
setRole
(
int
role
);
/**
* Get the role hint for this {@code BeanDefinition}. The role hint
...
...
@@ -275,12 +289,41 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
*/
int
getRole
();
/**
* Set a human-readable description of this bean definition.
* @since 5.1
*/
void
setDescription
(
@Nullable
String
description
);
/**
* Return a human-readable description of this bean definition.
*/
@Nullable
String
getDescription
();
// Read-only attributes
/**
* Return whether this a <b>Singleton</b>, with a single, shared instance
* returned on all calls.
* @see #SCOPE_SINGLETON
*/
boolean
isSingleton
();
/**
* Return whether this a <b>Prototype</b>, with an independent instance
* returned for each call.
* @since 3.0
* @see #SCOPE_PROTOTYPE
*/
boolean
isPrototype
();
/**
* Return whether this bean is "abstract", that is, not meant to be instantiated.
*/
boolean
isAbstract
();
/**
* Return a description of the resource that this bean definition
* came from (for the purpose of showing context in case of errors).
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java
浏览文件 @
97cea7f3
...
...
@@ -878,6 +878,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
* Set the name of the initializer method.
* <p>The default is {@code null} in which case there is no initializer method.
*/
@Override
public
void
setInitMethodName
(
@Nullable
String
initMethodName
)
{
this
.
initMethodName
=
initMethodName
;
}
...
...
@@ -885,6 +886,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Return the name of the initializer method.
*/
@Override
@Nullable
public
String
getInitMethodName
()
{
return
this
.
initMethodName
;
...
...
@@ -911,6 +913,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
* Set the name of the destroy method.
* <p>The default is {@code null} in which case there is no destroy method.
*/
@Override
public
void
setDestroyMethodName
(
@Nullable
String
destroyMethodName
)
{
this
.
destroyMethodName
=
destroyMethodName
;
}
...
...
@@ -918,6 +921,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Return the name of the destroy method.
*/
@Override
@Nullable
public
String
getDestroyMethodName
()
{
return
this
.
destroyMethodName
;
...
...
@@ -960,6 +964,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Set the role hint for this {@code BeanDefinition}.
*/
@Override
public
void
setRole
(
int
role
)
{
this
.
role
=
role
;
}
...
...
@@ -975,6 +980,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Set a human-readable description of this bean definition.
*/
@Override
public
void
setDescription
(
@Nullable
String
description
)
{
this
.
description
=
description
;
}
...
...
spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java
浏览文件 @
97cea7f3
...
...
@@ -25,7 +25,6 @@ import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.BeanDefinitionHolder
;
import
org.springframework.beans.factory.support.AbstractBeanDefinition
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.beans.factory.support.DefaultListableBeanFactory
;
import
org.springframework.beans.factory.support.RootBeanDefinition
;
...
...
@@ -255,16 +254,13 @@ public abstract class AnnotationConfigUtils {
abd
.
setDependsOn
(
dependsOn
.
getStringArray
(
"value"
));
}
if
(
abd
instanceof
AbstractBeanDefinition
)
{
AbstractBeanDefinition
absBd
=
(
AbstractBeanDefinition
)
abd
;
AnnotationAttributes
role
=
attributesFor
(
metadata
,
Role
.
class
);
if
(
role
!=
null
)
{
absBd
.
setRole
(
role
.
getNumber
(
"value"
).
intValue
());
}
AnnotationAttributes
description
=
attributesFor
(
metadata
,
Description
.
class
);
if
(
description
!=
null
)
{
absBd
.
setDescription
(
description
.
getString
(
"value"
));
}
AnnotationAttributes
role
=
attributesFor
(
metadata
,
Role
.
class
);
if
(
role
!=
null
)
{
abd
.
setRole
(
role
.
getNumber
(
"value"
).
intValue
());
}
AnnotationAttributes
description
=
attributesFor
(
metadata
,
Description
.
class
);
if
(
description
!=
null
)
{
abd
.
setDescription
(
description
.
getString
(
"value"
));
}
}
...
...
spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java
浏览文件 @
97cea7f3
...
...
@@ -41,7 +41,6 @@ import org.springframework.beans.factory.FactoryBean;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
;
import
org.springframework.beans.factory.support.AbstractBeanDefinition
;
import
org.springframework.beans.factory.support.BeanDefinitionValidationException
;
import
org.springframework.beans.factory.support.DefaultListableBeanFactory
;
import
org.springframework.beans.factory.support.GenericBeanDefinition
;
...
...
@@ -516,16 +515,13 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
Signature
signature
=
new
Signature
(
setterName
,
Type
.
VOID_TYPE
,
new
Type
[]
{
Type
.
getType
(
propertyType
)});
maker
.
add
(
signature
,
new
Type
[
0
]);
}
if
(
bd
instanceof
AbstractBeanDefinition
)
{
AbstractBeanDefinition
abd
=
(
AbstractBeanDefinition
)
bd
;
if
(
abd
.
getInitMethodName
()
!=
null
)
{
Signature
signature
=
new
Signature
(
abd
.
getInitMethodName
(),
Type
.
VOID_TYPE
,
new
Type
[
0
]);
maker
.
add
(
signature
,
new
Type
[
0
]);
}
if
(
StringUtils
.
hasText
(
abd
.
getDestroyMethodName
()))
{
Signature
signature
=
new
Signature
(
abd
.
getDestroyMethodName
(),
Type
.
VOID_TYPE
,
new
Type
[
0
]);
maker
.
add
(
signature
,
new
Type
[
0
]);
}
if
(
bd
.
getInitMethodName
()
!=
null
)
{
Signature
signature
=
new
Signature
(
bd
.
getInitMethodName
(),
Type
.
VOID_TYPE
,
new
Type
[
0
]);
maker
.
add
(
signature
,
new
Type
[
0
]);
}
if
(
StringUtils
.
hasText
(
bd
.
getDestroyMethodName
()))
{
Signature
signature
=
new
Signature
(
bd
.
getDestroyMethodName
(),
Type
.
VOID_TYPE
,
new
Type
[
0
]);
maker
.
add
(
signature
,
new
Type
[
0
]);
}
return
maker
.
create
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录