Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
dfab5145
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,发现更多精彩内容 >>
提交
dfab5145
编写于
3月 06, 2009
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polish
上级
2e7e9824
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
86 deletion
+32
-86
org.springframework.config.java/src/main/java/org/springframework/config/java/NoOpInterceptor.java
...java/org/springframework/config/java/NoOpInterceptor.java
+0
-32
org.springframework.config.java/src/main/java/org/springframework/config/java/StandardScopes.java
.../java/org/springframework/config/java/StandardScopes.java
+5
-6
org.springframework.config.java/src/main/java/org/springframework/config/java/internal/enhancement/ConfigurationEnhancer.java
...nfig/java/internal/enhancement/ConfigurationEnhancer.java
+10
-47
org.springframework.config.java/src/test/java/org/springframework/config/java/support/ConfigurationPostProcessorTests.java
.../config/java/support/ConfigurationPostProcessorTests.java
+17
-1
未找到文件。
org.springframework.config.java/src/main/java/org/springframework/config/java/NoOpInterceptor.java
已删除
100644 → 0
浏览文件 @
2e7e9824
/*
* Copyright 2002-2009 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.config.java
;
import
java.lang.reflect.Method
;
import
net.sf.cglib.proxy.MethodInterceptor
;
import
net.sf.cglib.proxy.MethodProxy
;
public
class
NoOpInterceptor
implements
MethodInterceptor
{
public
static
final
NoOpInterceptor
INSTANCE
=
new
NoOpInterceptor
();
public
Object
intercept
(
Object
obj
,
Method
method
,
Object
[]
args
,
MethodProxy
proxy
)
throws
Throwable
{
return
null
;
}
}
org.springframework.config.java/src/main/java/org/springframework/config/java/StandardScopes.java
浏览文件 @
dfab5145
...
...
@@ -18,18 +18,17 @@ package org.springframework.config.java;
/**
* Enumerates the names of the scopes supported out of the box in Spring.
*
<p>
*
Not modeled as an actual java enum because annotations that accept a scope attribute must
*
allow for user-defined scope names. Given that java enums are not extensible, these must
* remain simple string constants.
*
*
<p>Not modeled as an actual java enum because annotations that accept a scope attribute
*
must allow for user-defined scope names. Given that java enums are not extensible, these
*
must
remain simple string constants.
*
* @author Chris Beams
* @since 3.0
*/
public
class
StandardScopes
{
private
StandardScopes
()
{
}
private
StandardScopes
()
{
}
public
static
final
String
SINGLETON
=
"singleton"
;
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/internal/enhancement/ConfigurationEnhancer.java
浏览文件 @
dfab5145
...
...
@@ -29,21 +29,19 @@ import net.sf.cglib.core.DefaultGeneratorStrategy;
import
net.sf.cglib.proxy.Callback
;
import
net.sf.cglib.proxy.CallbackFilter
;
import
net.sf.cglib.proxy.Enhancer
;
import
net.sf.cglib.proxy.MethodInterceptor
;
import
net.sf.cglib.proxy.MethodProxy
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.objectweb.asm.ClassAdapter
;
import
org.objectweb.asm.ClassReader
;
import
org.objectweb.asm.ClassWriter
;
import
org.springframework.beans.factory.BeanFactoryAware
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.beans.factory.support.DefaultListableBeanFactory
;
import
org.springframework.config.java.BeanDefinitionRegistrar
;
import
org.springframework.config.java.BeanMethod
;
import
org.springframework.config.java.Configuration
;
import
org.springframework.config.java.ConfigurationClass
;
import
org.springframework.config.java.ConfigurationModel
;
import
org.springframework.config.java.NoOpInterceptor
;
import
org.springframework.config.java.ext.BeanMethodInterceptor
;
import
org.springframework.config.java.ext.BeanRegistrar
;
...
...
@@ -85,15 +83,13 @@ public class ConfigurationEnhancer {
*/
public
ConfigurationEnhancer
(
DefaultListableBeanFactory
beanFactory
)
{
notNull
(
beanFactory
,
"beanFactory must be non-null"
);
//notNull(model, "model must be non-null");
//populateRegistrarsAndCallbacks(beanFactory, model);
registrars
.
add
(
new
BeanRegistrar
());
BeanMethodInterceptor
beanMethodInterceptor
=
new
BeanMethodInterceptor
();
beanMethodInterceptor
.
setBeanFactory
(
beanFactory
);
callbackInstances
.
add
(
beanMethodInterceptor
);
// add no-op default registrar and method interceptor
registrars
.
add
(
new
BeanDefinitionRegistrar
()
{
public
boolean
accepts
(
Method
method
)
{
...
...
@@ -104,48 +100,15 @@ public class ConfigurationEnhancer {
// no-op
}
});
callbackInstances
.
add
(
NoOpInterceptor
.
INSTANCE
);
for
(
Callback
callback
:
callbackInstances
)
callbackTypes
.
add
(
callback
.
getClass
());
}
/**
* Reads the contents of {@code model} in order to populate {@link #registrars},
* {@link #callbackInstances} and {@link #callbackTypes} appropriately.
*
* @see #callbackFilter
*/
private
void
populateRegistrarsAndCallbacks
(
DefaultListableBeanFactory
beanFactory
,
ConfigurationModel
model
)
{
for
(
ConfigurationClass
configClass
:
model
.
getAllConfigurationClasses
())
{
for
(
BeanMethod
method
:
configClass
.
getMethods
())
{
registrars
.
add
(
new
BeanRegistrar
());
callbackInstances
.
add
(
new
MethodInterceptor
()
{
Callback
callback
=
new
BeanMethodInterceptor
();
if
(
callback
instanceof
BeanFactoryAware
)
((
BeanFactoryAware
)
callback
).
setBeanFactory
(
beanFactory
);
callbackInstances
.
add
(
callback
);
}
}
// register a 'catch-all' registrar
registrars
.
add
(
new
BeanDefinitionRegistrar
()
{
public
boolean
accepts
(
Method
method
)
{
return
true
;
}
public
void
register
(
BeanMethod
method
,
BeanDefinitionRegistry
registry
)
{
// no-op
}
public
Object
intercept
(
Object
obj
,
Method
method
,
Object
[]
args
,
MethodProxy
proxy
)
throws
Throwable
{
return
null
;
}
});
callbackInstances
.
add
(
NoOpInterceptor
.
INSTANCE
);
for
(
Callback
callback
:
callbackInstances
)
callbackTypes
.
add
(
callback
.
getClass
());
}
...
...
org.springframework.config.java/src/test/java/org/springframework/config/java/support/ConfigurationPostProcessorTests.java
浏览文件 @
dfab5145
/*
* Copyright 2002-2009 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.config.java.support
;
import
static
org
.
hamcrest
.
CoreMatchers
.*;
...
...
@@ -13,8 +28,9 @@ import org.springframework.config.java.Configuration;
import
org.springframework.config.java.ext.Bean
;
import
org.springframework.util.ClassUtils
;
/**
* Unit tests for {@link ConfigurationClassPostProcessor}
* Unit tests for {@link ConfigurationClassPostProcessor}
.
*
* @author Chris Beams
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录