Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
dc191bec
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,发现更多精彩内容 >>
提交
dc191bec
编写于
3月 07, 2009
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Whitespace and license polish
上级
a2c87ae6
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
144 addition
and
148 deletion
+144
-148
org.springframework.config.java/src/main/java/org/springframework/config/java/support/AbstractConfigurationClassProcessor.java
...fig/java/support/AbstractConfigurationClassProcessor.java
+20
-20
org.springframework.config.java/src/main/java/org/springframework/config/java/support/AddAnnotationAdapter.java
...ngframework/config/java/support/AddAnnotationAdapter.java
+3
-4
org.springframework.config.java/src/main/java/org/springframework/config/java/support/AnnotationAdapter.java
...pringframework/config/java/support/AnnotationAdapter.java
+1
-1
org.springframework.config.java/src/main/java/org/springframework/config/java/support/AsmUtils.java
...ava/org/springframework/config/java/support/AsmUtils.java
+2
-5
org.springframework.config.java/src/main/java/org/springframework/config/java/support/BeanDefinitionRegistrar.java
...ramework/config/java/support/BeanDefinitionRegistrar.java
+15
-0
org.springframework.config.java/src/main/java/org/springframework/config/java/support/BeanMethod.java
...a/org/springframework/config/java/support/BeanMethod.java
+11
-11
org.springframework.config.java/src/main/java/org/springframework/config/java/support/BeanMethodInterceptor.java
...gframework/config/java/support/BeanMethodInterceptor.java
+3
-3
org.springframework.config.java/src/main/java/org/springframework/config/java/support/BeanRegistrar.java
...rg/springframework/config/java/support/BeanRegistrar.java
+18
-6
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationClass.java
...ringframework/config/java/support/ConfigurationClass.java
+9
-13
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationClassMethodVisitor.java
.../config/java/support/ConfigurationClassMethodVisitor.java
+8
-8
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationClassPostProcessor.java
.../config/java/support/ConfigurationClassPostProcessor.java
+2
-2
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationClassVisitor.java
...mework/config/java/support/ConfigurationClassVisitor.java
+5
-7
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationEnhancer.java
...gframework/config/java/support/ConfigurationEnhancer.java
+11
-12
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationModel.java
...ringframework/config/java/support/ConfigurationModel.java
+4
-7
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationModelBeanDefinitionReader.java
.../java/support/ConfigurationModelBeanDefinitionReader.java
+5
-23
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationParser.java
...ingframework/config/java/support/ConfigurationParser.java
+3
-3
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ModelClass.java
...a/org/springframework/config/java/support/ModelClass.java
+3
-2
org.springframework.config.java/src/main/java/org/springframework/config/java/support/MutableAnnotationArrayVisitor.java
...rk/config/java/support/MutableAnnotationArrayVisitor.java
+1
-6
org.springframework.config.java/src/main/java/org/springframework/config/java/support/MutableAnnotationInvocationHandler.java
...nfig/java/support/MutableAnnotationInvocationHandler.java
+1
-2
org.springframework.config.java/src/main/java/org/springframework/config/java/support/MutableAnnotationUtils.java
...framework/config/java/support/MutableAnnotationUtils.java
+1
-2
org.springframework.config.java/src/main/java/org/springframework/config/java/support/MutableAnnotationVisitor.java
...amework/config/java/support/MutableAnnotationVisitor.java
+1
-5
org.springframework.config.java/src/main/java/org/springframework/config/java/support/Util.java
...in/java/org/springframework/config/java/support/Util.java
+17
-6
未找到文件。
org.springframework.config.java/src/main/java/org/springframework/config/java/support/AbstractConfigurationClassProcessor.java
浏览文件 @
dc191bec
...
...
@@ -43,7 +43,7 @@ import org.springframework.config.java.Configuration;
* @see ConfigurationClassPostProcessor
*/
public
abstract
class
AbstractConfigurationClassProcessor
{
/**
* Used to register any problems detected with {@link Configuration} or {@link Bean}
* declarations. For instance, a Bean method marked as {@literal final} is illegal
...
...
@@ -62,7 +62,7 @@ public abstract class AbstractConfigurationClassProcessor {
* @see #processConfigBeanDefinitions()
*/
protected
abstract
BeanDefinitionRegistry
getConfigurationBeanDefinitions
(
boolean
includeAbstractBeanDefs
);
/**
* Create and return a new {@link ConfigurationParser}, allowing for customization of
* type (ASM/JDT/Reflection) as well as providing specialized ClassLoader during
...
...
@@ -70,7 +70,7 @@ public abstract class AbstractConfigurationClassProcessor {
* @see #processConfigBeanDefinitions()
*/
protected
abstract
ConfigurationParser
createConfigurationParser
();
/**
* Validate the given model and handle any errors. Implementations may choose to throw
* {@link BeanDefinitionParsingException}, or in the case of tooling register problems
...
...
@@ -78,7 +78,7 @@ public abstract class AbstractConfigurationClassProcessor {
* @param configModel {@link ConfigurationModel} to validate
*/
protected
abstract
void
validateModel
(
ConfigurationModel
configModel
);
/**
* Override the default {@link ProblemReporter}.
* @param problemReporter custom problem reporter
...
...
@@ -86,14 +86,14 @@ public abstract class AbstractConfigurationClassProcessor {
protected
final
void
setProblemReporter
(
ProblemReporter
problemReporter
)
{
this
.
problemReporter
=
problemReporter
;
}
/**
* Get the currently registered {@link ProblemReporter}.
*/
protected
final
ProblemReporter
getProblemReporter
()
{
return
problemReporter
;
}
/**
* Build and validate a {@link ConfigurationModel} based on the registry of
* {@link Configuration} classes provided by {@link #getConfigurationBeanDefinitions},
...
...
@@ -105,28 +105,28 @@ public abstract class AbstractConfigurationClassProcessor {
*/
protected
final
BeanDefinitionRegistry
processConfigBeanDefinitions
()
{
BeanDefinitionRegistry
configBeanDefs
=
getConfigurationBeanDefinitions
(
false
);
// return an empty registry immediately if no @Configuration classes were found
if
(
configBeanDefs
.
getBeanDefinitionCount
()
==
0
)
return
configBeanDefs
;
// populate a new ConfigurationModel by parsing each @Configuration classes
ConfigurationParser
parser
=
createConfigurationParser
();
for
(
String
beanName
:
configBeanDefs
.
getBeanDefinitionNames
())
{
BeanDefinition
beanDef
=
configBeanDefs
.
getBeanDefinition
(
beanName
);
String
className
=
beanDef
.
getBeanClassName
();
parser
.
parse
(
className
,
beanName
);
}
for
(
String
beanName
:
configBeanDefs
.
getBeanDefinitionNames
())
{
BeanDefinition
beanDef
=
configBeanDefs
.
getBeanDefinition
(
beanName
);
String
className
=
beanDef
.
getBeanClassName
();
parser
.
parse
(
className
,
beanName
);
}
ConfigurationModel
configModel
=
parser
.
getConfigurationModel
();
// validate the ConfigurationModel
validateModel
(
configModel
);
// read the model and create bean definitions based on its content
return
new
ConfigurationModelBeanDefinitionReader
().
loadBeanDefinitions
(
configModel
);
}
return
new
ConfigurationModelBeanDefinitionReader
().
loadBeanDefinitions
(
configModel
);
}
}
org.springframework.config.java/src/main/java/org/springframework/config/java/support/AddAnnotationAdapter.java
浏览文件 @
dc191bec
...
...
@@ -53,8 +53,8 @@ class AddAnnotationAdapter extends ClassAdapter {
* Ensures that the version of the resulting class is Java 5 or better.
*/
@Override
public
void
visit
(
int
version
,
int
access
,
String
name
,
String
signature
,
String
superName
,
String
[]
interfaces
)
{
public
void
visit
(
int
version
,
int
access
,
String
name
,
String
signature
,
String
superName
,
String
[]
interfaces
)
{
int
v
=
(
version
&
0xFF
)
<
Constants
.
V1_5
?
Constants
.
V1_5
:
version
;
cv
.
visit
(
v
,
access
,
name
,
signature
,
superName
,
interfaces
);
}
...
...
@@ -83,8 +83,7 @@ class AddAnnotationAdapter extends ClassAdapter {
}
@Override
public
MethodVisitor
visitMethod
(
int
access
,
String
name
,
String
desc
,
String
signature
,
String
[]
exceptions
)
{
public
MethodVisitor
visitMethod
(
int
access
,
String
name
,
String
desc
,
String
signature
,
String
[]
exceptions
)
{
addAnnotation
();
return
cv
.
visitMethod
(
access
,
name
,
desc
,
signature
,
exceptions
);
}
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/AnnotationAdapter.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/AsmUtils.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -109,8 +109,6 @@ class AsmUtils {
*
* @param bytes byte array that will be provided as input to the new ClassReader
* instance.
*
* @return
*/
public
static
ClassReader
newClassReader
(
byte
[]
bytes
)
{
return
new
ClassReader
(
bytes
);
...
...
@@ -129,8 +127,7 @@ class AsmUtils {
try
{
return
new
ClassReader
(
is
);
}
catch
(
IOException
ex
)
{
throw
new
RuntimeException
(
"An unexpected exception occurred while creating ASM ClassReader: "
+
ex
);
throw
new
RuntimeException
(
"An unexpected exception occurred while creating ASM ClassReader: "
+
ex
);
}
finally
{
try
{
is
.
close
();
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/BeanDefinitionRegistrar.java
浏览文件 @
dc191bec
/*
* 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
java.lang.reflect.Method
;
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/BeanMethod.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -140,8 +140,8 @@ final class BeanMethod {
@Override
public
String
toString
()
{
String
returnTypeName
=
returnType
==
null
?
"<unknown>"
:
returnType
.
getSimpleName
();
return
String
.
format
(
"%s: name=%s; returnType=%s; modifiers=%d"
,
getClass
().
getSimpleName
(),
name
,
returnTypeName
,
modifiers
);
return
format
(
"%s: name=%s; returnType=%s; modifiers=%d"
,
getClass
().
getSimpleName
(),
name
,
returnTypeName
,
modifiers
);
}
@Override
...
...
@@ -187,24 +187,24 @@ final class BeanMethod {
/** {@link Bean} methods must be non-private in order to accommodate CGLIB. */
public
class
PrivateMethodError
extends
Problem
{
public
PrivateMethodError
()
{
super
(
format
(
"method '%s' may not be private"
,
getName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
)));
super
(
format
(
"method '%s' may not be private"
,
getName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
)));
}
}
/** {@link Bean} methods must be non-final in order to accommodate CGLIB. */
public
class
FinalMethodError
extends
Problem
{
public
FinalMethodError
()
{
super
(
format
(
"method '%s' may not be final. remove the final modifier to continue"
,
getName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
)));
super
(
format
(
"method '%s' may not be final. remove the final modifier to continue"
,
getName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
)));
}
}
public
class
InvalidScopedProxyDeclarationError
extends
Problem
{
public
InvalidScopedProxyDeclarationError
(
BeanMethod
method
)
{
super
(
String
.
format
(
"method %s contains an invalid annotation declaration: scoped proxies "
+
"cannot be created for singleton/prototype beans"
,
method
.
getName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
))
);
super
(
format
(
"method %s contains an invalid annotation declaration: scoped proxies "
+
"cannot be created for singleton/prototype beans"
,
method
.
getName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
)));
}
}
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/BeanMethodInterceptor.java
浏览文件 @
dc191bec
...
...
@@ -59,7 +59,7 @@ class BeanMethodInterceptor implements BeanFactoryAware, MethodInterceptor {
* existence of this bean object.
*/
public
Object
intercept
(
Object
obj
,
Method
method
,
Object
[]
args
,
MethodProxy
proxy
)
throws
Throwable
{
// determine the name of the bean
String
beanName
;
// check to see if the user has explicitly set the bean name
...
...
@@ -83,8 +83,8 @@ class BeanMethodInterceptor implements BeanFactoryAware, MethodInterceptor {
// we have an already existing cached instance of this bean -> retrieve it
Object
cachedBean
=
beanFactory
.
getBean
(
beanName
);
if
(
log
.
isInfoEnabled
())
log
.
info
(
format
(
"Returning cached singleton object [%s] for @Bean method %s.%s"
,
cachedBean
,
method
.
getDeclaringClass
().
getSimpleName
(),
beanName
));
log
.
info
(
format
(
"Returning cached singleton object [%s] for @Bean method %s.%s"
,
cachedBean
,
method
.
getDeclaringClass
().
getSimpleName
(),
beanName
));
return
cachedBean
;
}
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/BeanRegistrar.java
浏览文件 @
dc191bec
/*
* 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
java
.
lang
.
String
.*;
...
...
@@ -24,12 +39,10 @@ import org.springframework.core.annotation.AnnotationUtils;
import
org.springframework.util.Assert
;
// TODO: SJC-242 document BeanHandler
// TODO: SJC-242 make package-private
class
BeanRegistrar
implements
BeanDefinitionRegistrar
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
BeanRegistrar
.
class
);
/** Prefix used when registering the target object for a scoped proxy. */
private
static
final
String
TARGET_NAME_PREFIX
=
"scopedTarget."
;
...
...
@@ -41,7 +54,6 @@ class BeanRegistrar implements BeanDefinitionRegistrar {
return
AnnotationUtils
.
findAnnotation
(
method
,
Bean
.
class
)
!=
null
;
}
// TODO: SJC-242 method too long
public
void
register
(
BeanMethod
method
,
BeanDefinitionRegistry
registry
)
{
RootBeanDefinition
beanDef
=
new
ConfigurationClassBeanDefinition
();
...
...
@@ -51,7 +63,7 @@ class BeanRegistrar implements BeanDefinitionRegistrar {
beanDef
.
setFactoryMethodName
(
method
.
getName
());
Bean
bean
=
method
.
getRequiredAnnotation
(
Bean
.
class
);
// TODO: prune defaults
//Configuration defaults = configClass.getMetadata();
...
...
@@ -119,7 +131,7 @@ class BeanRegistrar implements BeanDefinitionRegistrar {
// is this method annotated with @Scope(scopedProxy=...)?
if
(
scope
!=
null
&&
scope
.
proxyMode
()
!=
ScopedProxyMode
.
NO
)
{
RootBeanDefinition
targetDef
=
beanDef
;
//
// Create a scoped proxy definition for the original bean name,
// "hiding" the target bean in an internal target definition.
String
targetBeanName
=
resolveHiddenScopedProxyBeanName
(
beanName
);
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationClass.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -15,7 +15,6 @@
*/
package
org.springframework.config.java.support
;
import
static
java
.
lang
.
String
.*;
import
java.lang.annotation.Annotation
;
...
...
@@ -147,7 +146,6 @@ final class ConfigurationClass extends ModelClass {
return
this
;
}
public
ConfigurationClass
setDeclaringClass
(
ConfigurationClass
configurationClass
)
{
this
.
declaringClass
=
configurationClass
;
return
this
;
...
...
@@ -190,7 +188,6 @@ final class ConfigurationClass extends ModelClass {
method
.
validate
(
problemReporter
);
}
@Override
public
String
toString
()
{
return
format
(
"%s; modifiers=%d; methods=%s"
,
super
.
toString
(),
modifiers
,
methods
);
...
...
@@ -252,23 +249,22 @@ final class ConfigurationClass extends ModelClass {
/** Configuration classes must be annotated with {@link Configuration @Configuration}. */
public
class
NonAnnotatedConfigurationError
extends
Problem
{
public
NonAnnotatedConfigurationError
()
{
super
(
format
(
"%s was provided as a Java Configuration class but was not annotated with @%s. "
+
"Update the class definition to continue."
,
getSimpleName
(),
Configuration
.
class
.
getSimpleName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
))
super
(
format
(
"%s was provided as a Java Configuration class but was not annotated with @%s. "
+
"Update the class definition to continue."
,
getSimpleName
(),
Configuration
.
class
.
getSimpleName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
))
);
}
}
/** Configuration classes must be non-final to accommodate CGLIB subclassing. */
public
class
FinalConfigurationError
extends
Problem
{
public
FinalConfigurationError
()
{
super
(
format
(
"@%s class may not be final. Remove the final modifier to continue."
,
Configuration
.
class
.
getSimpleName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
))
super
(
format
(
"@%s class may not be final. Remove the final modifier to continue."
,
Configuration
.
class
.
getSimpleName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
))
);
}
}
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationClassMethodVisitor.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -60,7 +60,7 @@ class ConfigurationClassMethodVisitor extends MethodAdapter {
* @param modifiers modifiers for this method
*/
public
ConfigurationClassMethodVisitor
(
ConfigurationClass
configClass
,
String
methodName
,
String
methodDescriptor
,
int
modifiers
,
ClassLoader
classLoader
)
{
String
methodDescriptor
,
int
modifiers
,
ClassLoader
classLoader
)
{
super
(
AsmUtils
.
EMPTY_VISITOR
);
this
.
configClass
=
configClass
;
...
...
@@ -133,12 +133,12 @@ class ConfigurationClassMethodVisitor extends MethodAdapter {
// detect whether the return type is an interface
newClassReader
(
convertClassNameToResourcePath
(
returnType
.
getName
()),
classLoader
).
accept
(
new
ClassAdapter
(
AsmUtils
.
EMPTY_VISITOR
)
{
@Override
public
void
visit
(
int
arg0
,
int
arg1
,
String
arg2
,
String
arg3
,
String
arg4
,
String
[]
arg5
)
{
returnType
.
setInterface
((
arg1
&
Opcodes
.
ACC_INTERFACE
)
==
Opcodes
.
ACC_INTERFACE
);
}
},
false
);
new
ClassAdapter
(
AsmUtils
.
EMPTY_VISITOR
)
{
@Override
public
void
visit
(
int
arg0
,
int
arg1
,
String
arg2
,
String
arg3
,
String
arg4
,
String
[]
arg5
)
{
returnType
.
setInterface
((
arg1
&
Opcodes
.
ACC_INTERFACE
)
==
Opcodes
.
ACC_INTERFACE
);
}
},
false
);
return
returnType
;
}
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationClassPostProcessor.java
浏览文件 @
dc191bec
...
...
@@ -161,8 +161,8 @@ public class ConfigurationClassPostProcessor extends AbstractConfigurationClassP
String
enhancedClassName
=
enhancer
.
enhance
(
configClassName
);
if
(
logger
.
isDebugEnabled
())
logger
.
debug
(
format
(
"Replacing bean definition '%s' existing class name '%s'
with enhanced class name '%s'"
,
beanName
,
configClassName
,
enhancedClassName
));
logger
.
debug
(
format
(
"Replacing bean definition '%s' existing class name '%s'
"
+
"with enhanced class name '%s'"
,
beanName
,
configClassName
,
enhancedClassName
));
beanDef
.
setBeanClassName
(
enhancedClassName
);
}
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationClassVisitor.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -22,8 +22,6 @@ import static org.springframework.util.ClassUtils.*;
import
java.lang.annotation.Annotation
;
import
java.util.HashMap
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.objectweb.asm.AnnotationVisitor
;
import
org.objectweb.asm.ClassAdapter
;
import
org.objectweb.asm.ClassReader
;
...
...
@@ -40,7 +38,6 @@ import org.springframework.config.java.Configuration;
*/
class
ConfigurationClassVisitor
extends
ClassAdapter
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
ConfigurationClassVisitor
.
class
);
private
static
final
String
OBJECT_DESC
=
convertClassNameToResourcePath
(
Object
.
class
.
getName
());
private
final
ConfigurationClass
configClass
;
...
...
@@ -63,15 +60,16 @@ class ConfigurationClassVisitor extends ClassAdapter {
@Override
public
void
visitSource
(
String
sourceFile
,
String
debug
)
{
String
resourcePath
=
convertClassNameToResourcePath
(
configClass
.
getName
()).
substring
(
0
,
configClass
.
getName
().
lastIndexOf
(
'.'
)
+
1
).
concat
(
sourceFile
);
String
resourcePath
=
convertClassNameToResourcePath
(
configClass
.
getName
())
.
substring
(
0
,
configClass
.
getName
().
lastIndexOf
(
'.'
)
+
1
).
concat
(
sourceFile
);
configClass
.
setSource
(
resourcePath
);
}
@Override
public
void
visit
(
int
classVersion
,
int
modifiers
,
String
classTypeDesc
,
String
arg3
,
String
superTypeDesc
,
String
[]
arg5
)
{
String
superTypeDesc
,
String
[]
arg5
)
{
visitSuperType
(
superTypeDesc
);
configClass
.
setName
(
convertResourcePathToClassName
(
classTypeDesc
));
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationEnhancer.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -67,9 +67,10 @@ class ConfigurationEnhancer {
if
(
iter
.
next
().
accepts
(
candidateMethod
))
return
i
;
throw
new
IllegalStateException
(
format
(
"No registrar is capable of "
+
"handling method [%s]. Perhaps you forgot to add a catch-all registrar?"
,
candidateMethod
.
getName
()));
throw
new
IllegalStateException
(
format
(
"No registrar is capable of handling method [%s]. "
+
"Perhaps you forgot to add a catch-all registrar?"
,
candidateMethod
.
getName
()));
}
};
...
...
@@ -98,10 +99,9 @@ class ConfigurationEnhancer {
});
callbackInstances
.
add
(
new
MethodInterceptor
()
{
public
Object
intercept
(
Object
obj
,
Method
method
,
Object
[]
args
,
MethodProxy
proxy
)
throws
Throwable
{
return
null
;
}
public
Object
intercept
(
Object
obj
,
Method
method
,
Object
[]
args
,
MethodProxy
proxy
)
throws
Throwable
{
return
null
;
}
});
...
...
@@ -127,8 +127,8 @@ class ConfigurationEnhancer {
subclass
=
nestOneClassDeeperIfAspect
(
superclass
,
subclass
);
if
(
log
.
isInfoEnabled
())
log
.
info
(
format
(
"Successfully enhanced %s; enhanced class name is: %s"
,
configClassName
,
subclass
.
getName
()));
log
.
info
(
format
(
"Successfully enhanced %s; enhanced class name is: %s"
,
configClassName
,
subclass
.
getName
()));
return
subclass
.
getName
();
}
...
...
@@ -193,8 +193,7 @@ class ConfigurationEnhancer {
@Override
protected
byte
[]
transform
(
byte
[]
b
)
throws
Exception
{
ClassWriter
writer
=
new
ClassWriter
(
false
);
ClassAdapter
adapter
=
new
AddAnnotationAdapter
(
writer
,
"Lorg/aspectj/lang/annotation/Aspect;"
);
ClassAdapter
adapter
=
new
AddAnnotationAdapter
(
writer
,
"Lorg/aspectj/lang/annotation/Aspect;"
);
ClassReader
reader
=
new
ClassReader
(
b
);
reader
.
accept
(
adapter
,
false
);
return
writer
.
toByteArray
();
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationModel.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -26,7 +26,6 @@ import org.springframework.config.java.Configuration;
import
org.springframework.core.io.FileSystemResource
;
/**
* An abstract representation of a set of user-provided "Configuration classes", usually but
* not necessarily annotated with {@link Configuration @Configuration}. The model is
...
...
@@ -163,11 +162,9 @@ final class ConfigurationModel {
public
class
EmptyModelError
extends
Problem
{
public
EmptyModelError
()
{
super
(
format
(
"Configuration model was empty. Make sure at least one "
+
"@%s class has been specified."
,
Configuration
.
class
.
getSimpleName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
))
);
super
(
format
(
"Configuration model was empty. Make sure at least one "
+
"@%s class has been specified."
,
Configuration
.
class
.
getSimpleName
()),
new
Location
(
new
FileSystemResource
(
"/dev/null"
)));
}
}
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationModelBeanDefinitionReader.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -69,8 +69,7 @@ class ConfigurationModelBeanDefinitionReader {
/**
* Reads a particular {@link ConfigurationClass}, registering bean definitions for the
* class itself, all its {@link Bean} methods and all its {@link Extension}
* annotations.
* class itself, all its {@link Bean} methods
*/
private
void
loadBeanDefinitionsForConfigurationClass
(
ConfigurationClass
configClass
)
{
doLoadBeanDefinitionForConfigurationClass
(
configClass
);
...
...
@@ -90,18 +89,6 @@ class ConfigurationModelBeanDefinitionReader {
*/
private
void
doLoadBeanDefinitionForConfigurationClass
(
ConfigurationClass
configClass
)
{
// TODO: prune support for @Required
// Configuration metadata = configClass.getMetadata();
// if (metadata.checkRequired() == true) {
// RootBeanDefinition requiredAnnotationPostProcessor = new RootBeanDefinition();
// Class<?> beanClass = RequiredAnnotationBeanPostProcessor.class;
// String beanName = beanClass.getName() + "#0";
// requiredAnnotationPostProcessor.setBeanClass(beanClass);
// requiredAnnotationPostProcessor
// .setResourceDescription("ensures @Required methods have been invoked");
// registry.registerBeanDefinition(beanName, requiredAnnotationPostProcessor);
// }
GenericBeanDefinition
configBeanDef
=
new
GenericBeanDefinition
();
configBeanDef
.
setBeanClassName
(
configClass
.
getName
());
...
...
@@ -111,11 +98,9 @@ class ConfigurationModelBeanDefinitionReader {
// and potentially has PropertyValues and ConstructorArgs)
if
(
registry
.
containsBeanDefinition
(
configBeanName
))
{
if
(
log
.
isInfoEnabled
())
log
.
info
(
format
(
"Copying property and constructor arg values from existing bean definition for "
+
"@Configuration class %s to new bean definition"
,
configBeanName
));
AbstractBeanDefinition
existing
=
(
AbstractBeanDefinition
)
registry
.
getBeanDefinition
(
configBeanName
);
log
.
info
(
format
(
"Copying property and constructor arg values from existing bean definition for "
+
"@Configuration class %s to new bean definition"
,
configBeanName
));
AbstractBeanDefinition
existing
=
(
AbstractBeanDefinition
)
registry
.
getBeanDefinition
(
configBeanName
);
configBeanDef
.
setPropertyValues
(
existing
.
getPropertyValues
());
configBeanDef
.
setConstructorArgumentValues
(
existing
.
getConstructorArgumentValues
());
configBeanDef
.
setResource
(
existing
.
getResource
());
...
...
@@ -127,14 +112,12 @@ class ConfigurationModelBeanDefinitionReader {
registry
.
registerBeanDefinition
(
configBeanName
,
configBeanDef
);
}
/**
* Reads a particular {@link BeanMethod}, registering bean definitions with
* {@link #registry} based on its contents.
*/
private
void
loadBeanDefinitionsForModelMethod
(
BeanMethod
method
)
{
new
BeanRegistrar
().
register
(
method
,
registry
);
//method.getRegistrar().register(method, registry);
}
// @SuppressWarnings("unchecked")
...
...
@@ -170,5 +153,4 @@ class ConfigurationModelBeanDefinitionReader {
// }
// }
}
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ConfigurationParser.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -76,7 +76,7 @@ public class ConfigurationParser {
}
public
ConfigurationModel
getConfigurationModel
()
{
return
model
;
}
return
model
;
}
}
org.springframework.config.java/src/main/java/org/springframework/config/java/support/ModelClass.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -27,7 +27,6 @@ import org.springframework.util.ClassUtils;
*
* @author Chris Beams
*/
// TODO: Consider eliminating in favor of just ConfigurationClass
class
ModelClass
implements
BeanMetadataElement
{
private
String
name
;
...
...
@@ -161,3 +160,5 @@ class ModelClass implements BeanMetadataElement {
}
}
// TODO: Consider eliminating in favor of just ConfigurationClass
org.springframework.config.java/src/main/java/org/springframework/config/java/support/MutableAnnotationArrayVisitor.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -22,16 +22,11 @@ import java.lang.annotation.Annotation;
import
java.lang.reflect.Array
;
import
java.util.ArrayList
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.objectweb.asm.AnnotationVisitor
;
/** TODO: JAVADOC */
class
MutableAnnotationArrayVisitor
extends
AnnotationAdapter
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
MutableAnnotationArrayVisitor
.
class
);
private
final
ArrayList
<
Object
>
values
=
new
ArrayList
<
Object
>();
private
final
MutableAnnotation
mutableAnno
;
private
final
String
attribName
;
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/MutableAnnotationInvocationHandler.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -30,7 +30,6 @@ import org.springframework.util.ReflectionUtils;
import
org.springframework.util.StringUtils
;
/** TODO: JAVADOC */
final
class
MutableAnnotationInvocationHandler
implements
InvocationHandler
{
private
final
Class
<?
extends
Annotation
>
annoType
;
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/MutableAnnotationUtils.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -19,7 +19,6 @@ import java.lang.annotation.Annotation;
import
java.lang.reflect.Proxy
;
/** TODO: JAVADOC */
class
MutableAnnotationUtils
{
/**
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/MutableAnnotationVisitor.java
浏览文件 @
dc191bec
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -21,8 +21,6 @@ import static org.springframework.config.java.support.Util.*;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Field
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.objectweb.asm.AnnotationVisitor
;
import
org.objectweb.asm.Type
;
import
org.springframework.util.Assert
;
...
...
@@ -33,8 +31,6 @@ import org.springframework.util.Assert;
*/
class
MutableAnnotationVisitor
implements
AnnotationVisitor
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
MutableAnnotationVisitor
.
class
);
protected
final
MutableAnnotation
mutableAnno
;
private
final
ClassLoader
classLoader
;
...
...
org.springframework.config.java/src/main/java/org/springframework/config/java/support/Util.java
浏览文件 @
dc191bec
/*
* 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
java
.
lang
.
String
.*;
...
...
@@ -20,10 +35,6 @@ import sun.security.x509.Extension;
*
* @author Chris Beams
*/
// TODO: SJC-242 general - check cycles with s101
// TODO: SJC-242 general - check tabs & spaces
// TODO: SJC-242 general - check apache header
// TODO: SJC-242 rename, repackage, document
class
Util
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
Util
.
class
);
...
...
@@ -158,8 +169,8 @@ class Util {
InputStream
is
=
classLoader
.
getResourceAsStream
(
classFileName
);
if
(
is
==
null
)
throw
new
RuntimeException
(
new
FileNotFoundException
(
"Class file ["
+
classFileName
+
"] not found"
));
throw
new
RuntimeException
(
new
FileNotFoundException
(
"Class file ["
+
classFileName
+
"] not found"
));
return
is
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录