Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
9216b3e8
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,发现更多精彩内容 >>
提交
9216b3e8
编写于
3月 06, 2009
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed Validator interface and inlined its implementations
上级
c278e1e9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
38 addition
and
133 deletion
+38
-133
org.springframework.config.java/.classpath
org.springframework.config.java/.classpath
+2
-0
org.springframework.config.java/.project
org.springframework.config.java/.project
+11
-0
org.springframework.config.java/ivy.xml
org.springframework.config.java/ivy.xml
+1
-0
org.springframework.config.java/src/main/java/org/springframework/config/java/BeanMethod.java
...main/java/org/springframework/config/java/BeanMethod.java
+9
-58
org.springframework.config.java/src/main/java/org/springframework/config/java/ConfigurationModel.java
...a/org/springframework/config/java/ConfigurationModel.java
+15
-63
org.springframework.config.java/src/main/java/org/springframework/config/java/Validatable.java
...ain/java/org/springframework/config/java/Validatable.java
+0
-2
org.springframework.config.java/src/main/java/org/springframework/config/java/Validator.java
.../main/java/org/springframework/config/java/Validator.java
+0
-10
未找到文件。
org.springframework.config.java/.classpath
浏览文件 @
9216b3e8
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"var"
path=
"CLOVER_RUNTIME"
/>
<classpathentry
including=
"**/*.java"
kind=
"src"
path=
"src/main/java"
/>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"src/test/java"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER"
/>
...
...
@@ -12,5 +13,6 @@
<classpathentry
combineaccessrules=
"false"
kind=
"src"
path=
"/org.springframework.beans"
/>
<classpathentry
combineaccessrules=
"false"
kind=
"src"
path=
"/org.springframework.core"
/>
<classpathentry
combineaccessrules=
"false"
kind=
"src"
path=
"/org.springframework.context"
/>
<classpathentry
combineaccessrules=
"false"
kind=
"src"
path=
"/org.springframework.aop"
/>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
</classpath>
org.springframework.config.java/.project
浏览文件 @
9216b3e8
...
...
@@ -10,11 +10,21 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
com.cenqua.clover.core.prejavabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
com.cenqua.clover.core.postjavabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.wst.validation.validationbuilder
</name>
<arguments>
...
...
@@ -32,5 +42,6 @@
<nature>
org.eclipse.wst.common.project.facet.core.nature
</nature>
<nature>
org.eclipse.wst.common.modulecore.ModuleCoreNature
</nature>
<nature>
org.eclipse.jem.workbench.JavaEMFNature
</nature>
<nature>
com.cenqua.clover.core.clovernature
</nature>
</natures>
</projectDescription>
org.springframework.config.java/ivy.xml
浏览文件 @
9216b3e8
...
...
@@ -28,6 +28,7 @@
<dependency
org=
"org.objectweb.asm"
name=
"com.springsource.org.objectweb.asm.commons"
rev=
"2.2.3"
conf=
"compile->compile"
/>
<dependency
org=
"org.springframework"
name=
"org.springframework.beans"
rev=
"latest.integration"
conf=
"compile->compile"
/>
<dependency
org=
"org.springframework"
name=
"org.springframework.context"
rev=
"latest.integration"
conf=
"compile->compile"
/>
<dependency
org=
"org.springframework"
name=
"org.springframework.aop"
rev=
"latest.integration"
conf=
"compile->compile"
/>
<!-- build time only dependencies -->
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/BeanMethod.java
浏览文件 @
9216b3e8
...
...
@@ -33,7 +33,6 @@ public final class BeanMethod implements Validatable {
private
final
List
<
Annotation
>
annotations
=
new
ArrayList
<
Annotation
>();
private
transient
ConfigurationClass
declaringClass
;
private
transient
int
lineNumber
;
private
transient
final
List
<
Validator
>
validators
=
new
ArrayList
<
Validator
>();
public
BeanMethod
(
String
name
,
int
modifiers
,
ModelClass
returnType
,
Annotation
...
annotations
)
{
Assert
.
hasText
(
name
);
...
...
@@ -117,10 +116,6 @@ public final class BeanMethod implements Validatable {
return
lineNumber
;
}
public
void
registerValidator
(
Validator
validator
)
{
validators
.
add
(
validator
);
}
public
void
validate
(
List
<
UsageError
>
errors
)
{
if
(
Modifier
.
isPrivate
(
getModifiers
()))
...
...
@@ -129,33 +124,16 @@ public final class BeanMethod implements Validatable {
if
(
Modifier
.
isFinal
(
getModifiers
()))
errors
.
add
(
new
FinalMethodError
());
new
BeanValidator
().
validate
(
this
,
errors
);
if
(
this
.
getAnnotation
(
ScopedProxy
.
class
)
==
null
)
return
;
Bean
bean
=
this
.
getRequiredAnnotation
(
Bean
.
class
);
if
(
bean
.
scope
().
equals
(
StandardScopes
.
SINGLETON
)
||
bean
.
scope
().
equals
(
StandardScopes
.
PROTOTYPE
))
errors
.
add
(
new
InvalidScopedProxyDeclarationError
(
this
));
}
// public BeanDefinitionRegistrar getRegistrar() {
// return getInstance(factoryAnno.registrar());
// }
// public Set<Validator> getValidators() {
// HashSet<Validator> validators = new HashSet<Validator>();
//
//// for (Class<? extends Validator> validatorType : factoryAnno.validators())
//// validator.add(getInstance(validatorType));
//
// validators.add(IllegalB)
//
// return validators;
// }
// public Callback getCallback() {
// Class<? extends Callback> callbackType = factoryAnno.interceptor();
//
// if (callbackType.equals(NoOpInterceptor.class))
// return NoOpInterceptor.INSTANCE;
//
// return getInstance(callbackType);
// }
//
@Override
public
String
toString
()
{
String
returnTypeName
=
returnType
==
null
?
"<unknown>"
:
returnType
.
getSimpleName
();
...
...
@@ -227,31 +205,4 @@ public final class BeanMethod implements Validatable {
}
}
}
/**
* Detects any user errors when declaring {@link Bean}-annotated methods.
*
* @author Chris Beams
*/
class
BeanValidator
implements
Validator
{
public
boolean
supports
(
Object
object
)
{
return
object
instanceof
BeanMethod
;
}
public
void
validate
(
Object
object
,
List
<
UsageError
>
errors
)
{
BeanMethod
method
=
(
BeanMethod
)
object
;
if
(
method
.
getAnnotation
(
ScopedProxy
.
class
)
==
null
)
return
;
Bean
bean
=
method
.
getRequiredAnnotation
(
Bean
.
class
);
if
(
bean
.
scope
().
equals
(
StandardScopes
.
SINGLETON
)
||
bean
.
scope
().
equals
(
StandardScopes
.
PROTOTYPE
))
errors
.
add
(
new
InvalidScopedProxyDeclarationError
(
method
));
}
}
}
\ No newline at end of file
org.springframework.config.java/src/main/java/org/springframework/config/java/ConfigurationModel.java
浏览文件 @
9216b3e8
...
...
@@ -43,7 +43,6 @@ public final class ConfigurationModel implements Validatable {
/* list is used because order and collection equality matters. */
private
final
ArrayList
<
ConfigurationClass
>
configurationClasses
=
new
ArrayList
<
ConfigurationClass
>();
private
final
ArrayList
<
Validator
>
validators
=
new
ArrayList
<
Validator
>();
/**
* Add a {@link Configuration @Configuration} class to the model. Classes may be added
...
...
@@ -57,10 +56,6 @@ public final class ConfigurationModel implements Validatable {
return
this
;
}
public
void
registerValidator
(
Validator
validator
)
{
validators
.
add
(
validator
);
}
/**
* Return configuration classes that have been directly added to this model.
*
...
...
@@ -96,7 +91,6 @@ public final class ConfigurationModel implements Validatable {
*
* @see ConfigurationClass#validate(java.util.List)
* @see BeanMethod#validate(java.util.List)
* @see Validator
* @see UsageError
*/
public
void
validate
(
List
<
UsageError
>
errors
)
{
...
...
@@ -104,27 +98,20 @@ public final class ConfigurationModel implements Validatable {
if
(
configurationClasses
.
isEmpty
())
errors
.
add
(
new
EmptyModelError
());
// cascade through model and allow handlers to register validators
// depending on where they are registered (with the model, the class, or the method)
// they will be called directly or indirectly below
// for (ConfigurationClass configClass : getAllConfigurationClasses()) {
// for (BeanMethod method : configClass.getMethods()) {
// for (Validator validator : method.getValidators()) {
// if (validator.supports(method))
// method.registerValidator(validator);
// // TODO: support class-level validation
// // if(validator.supports(configClass))
// // configClass.registerValidator(validator);
// if (validator.supports(this))
// this.registerValidator(validator);
// }
// }
// }
// process any validators registered directly with this model object
// for (Validator validator : validators)
// validator.validate(this, errors);
new
IllegalBeanOverrideValidator
().
validate
(
this
,
errors
);
// check for any illegal @Bean overriding
ConfigurationClass
[]
allClasses
=
getAllConfigurationClasses
();
for
(
int
i
=
0
;
i
<
allClasses
.
length
;
i
++)
{
for
(
BeanMethod
method
:
allClasses
[
i
].
getMethods
())
{
Bean
bean
=
method
.
getAnnotation
(
Bean
.
class
);
if
(
bean
==
null
||
bean
.
allowOverriding
())
continue
;
for
(
int
j
=
i
+
1
;
j
<
allClasses
.
length
;
j
++)
if
(
allClasses
[
j
].
hasMethod
(
method
.
getName
()))
errors
.
add
(
allClasses
[
i
].
new
IllegalBeanOverrideError
(
allClasses
[
j
],
method
));
}
}
// each individual configuration class must be well-formed
// note that each configClass detects usage errors on its imports recursively
...
...
@@ -176,39 +163,4 @@ public final class ConfigurationModel implements Validatable {
}
}
}
/**
* Detects any illegally-overridden {@link Bean} definitions within a particular
* {@link ConfigurationModel}
*
* @see Bean#allowOverriding()
*
* @author Chris Beams
*/
class
IllegalBeanOverrideValidator
implements
Validator
{
public
boolean
supports
(
Object
object
)
{
return
object
instanceof
ConfigurationModel
;
}
public
void
validate
(
Object
object
,
List
<
UsageError
>
errors
)
{
ConfigurationModel
model
=
(
ConfigurationModel
)
object
;
ConfigurationClass
[]
allClasses
=
model
.
getAllConfigurationClasses
();
for
(
int
i
=
0
;
i
<
allClasses
.
length
;
i
++)
{
for
(
BeanMethod
method
:
allClasses
[
i
].
getMethods
())
{
Bean
bean
=
method
.
getAnnotation
(
Bean
.
class
);
if
(
bean
==
null
||
bean
.
allowOverriding
())
continue
;
for
(
int
j
=
i
+
1
;
j
<
allClasses
.
length
;
j
++)
if
(
allClasses
[
j
].
hasMethod
(
method
.
getName
()))
errors
.
add
(
allClasses
[
i
].
new
IllegalBeanOverrideError
(
allClasses
[
j
],
method
));
}
}
}
}
}
\ No newline at end of file
org.springframework.config.java/src/main/java/org/springframework/config/java/Validatable.java
浏览文件 @
9216b3e8
...
...
@@ -6,8 +6,6 @@ import java.util.List;
/**
* Indicates a type is able to be validated for errors.
*
* @see Validator
*
* @author Chris Beams
*/
interface
Validatable
{
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/Validator.java
已删除
100644 → 0
浏览文件 @
c278e1e9
package
org.springframework.config.java
;
import
java.util.List
;
interface
Validator
{
boolean
supports
(
Object
object
);
void
validate
(
Object
object
,
List
<
UsageError
>
errors
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录