Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dk131072
spring-framework
提交
24d40fa3
S
spring-framework
项目概览
dk131072
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
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,发现更多精彩内容 >>
提交
24d40fa3
编写于
1月 13, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed resolveProxyTargetClass exception message
上级
bd87ff7f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
31 deletion
+39
-31
spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java
...amework/scripting/support/ScriptFactoryPostProcessor.java
+39
-31
未找到文件。
spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java
浏览文件 @
24d40fa3
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
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.
...
...
@@ -23,15 +23,11 @@ import java.util.Map;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.asm.Type
;
import
org.springframework.cglib.core.Signature
;
import
org.springframework.cglib.proxy.InterfaceMaker
;
import
org.springframework.aop.TargetSource
;
import
org.springframework.aop.framework.AopInfrastructureBean
;
import
org.springframework.aop.framework.ProxyFactory
;
import
org.springframework.aop.support.DelegatingIntroductionInterceptor
;
import
org.springframework.asm.Type
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.PropertyValue
;
import
org.springframework.beans.factory.BeanClassLoaderAware
;
...
...
@@ -50,6 +46,8 @@ 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
;
import
org.springframework.cglib.core.Signature
;
import
org.springframework.cglib.proxy.InterfaceMaker
;
import
org.springframework.context.ResourceLoaderAware
;
import
org.springframework.core.Conventions
;
import
org.springframework.core.Ordered
;
...
...
@@ -259,9 +257,11 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
Class
<?>
scriptedType
=
scriptFactory
.
getScriptedObjectType
(
scriptSource
);
if
(
scriptedType
!=
null
)
{
return
scriptedType
;
}
else
if
(!
ObjectUtils
.
isEmpty
(
interfaces
))
{
}
else
if
(!
ObjectUtils
.
isEmpty
(
interfaces
))
{
return
(
interfaces
.
length
==
1
?
interfaces
[
0
]
:
createCompositeInterface
(
interfaces
));
}
else
{
}
else
{
if
(
bd
.
isSingleton
())
{
Object
bean
=
this
.
scriptBeanFactory
.
getBean
(
scriptedObjectBeanName
);
if
(
bean
!=
null
)
{
...
...
@@ -269,14 +269,16 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
}
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
if
(
ex
instanceof
BeanCreationException
&&
((
BeanCreationException
)
ex
).
getMostSpecificCause
()
instanceof
BeanCurrentlyInCreationException
)
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Could not determine scripted object type for bean '"
+
beanName
+
"': "
+
ex
.
getMessage
());
}
}
else
{
}
else
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Could not determine scripted object type for bean '"
+
beanName
+
"'"
,
ex
);
}
...
...
@@ -307,9 +309,10 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
if
(
scriptedObjectType
!=
null
)
{
isFactoryBean
=
FactoryBean
.
class
.
isAssignableFrom
(
scriptedObjectType
);
}
}
catch
(
Exception
ex
)
{
throw
new
BeanCreationException
(
beanName
,
"Could not determine scripted object type for "
+
scriptFactory
,
ex
);
}
catch
(
Exception
ex
)
{
throw
new
BeanCreationException
(
beanName
,
"Could not determine scripted object type for "
+
scriptFactory
,
ex
);
}
long
refreshCheckDelay
=
resolveRefreshCheckDelay
(
bd
);
...
...
@@ -319,10 +322,10 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
scriptedObjectBeanName
,
scriptFactory
,
scriptSource
,
isFactoryBean
);
boolean
proxyTargetClass
=
resolveProxyTargetClass
(
bd
);
String
language
=
(
String
)
bd
.
getAttribute
(
LANGUAGE_ATTRIBUTE
);
if
(
proxyTargetClass
&&
(
language
==
null
||
!
language
.
equals
(
"groovy"
)))
{
if
(
proxyTargetClass
&&
(
language
==
null
||
!
language
.
equals
(
"groovy"
)))
{
throw
new
BeanDefinitionValidationException
(
"Cannot use proxyTargetClass=true with script beans where language is not
groovy (found "
+
language
+
")
"
);
"Cannot use proxyTargetClass=true with script beans where language is not
'groovy': '"
+
language
+
"'
"
);
}
ts
.
setRefreshCheckDelay
(
refreshCheckDelay
);
return
createRefreshableProxy
(
ts
,
interfaces
,
proxyTargetClass
);
...
...
@@ -389,12 +392,14 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
Object
attributeValue
=
beanDefinition
.
getAttribute
(
REFRESH_CHECK_DELAY_ATTRIBUTE
);
if
(
attributeValue
instanceof
Number
)
{
refreshCheckDelay
=
((
Number
)
attributeValue
).
longValue
();
}
else
if
(
attributeValue
instanceof
String
)
{
}
else
if
(
attributeValue
instanceof
String
)
{
refreshCheckDelay
=
Long
.
parseLong
((
String
)
attributeValue
);
}
else
if
(
attributeValue
!=
null
)
{
throw
new
BeanDefinitionStoreException
(
"Invalid refresh check delay attribute ["
+
REFRESH_CHECK_DELAY_ATTRIBUTE
+
"] with value ["
+
attributeValue
+
"]: needs to be of type Number or String"
);
}
else
if
(
attributeValue
!=
null
)
{
throw
new
BeanDefinitionStoreException
(
"Invalid refresh check delay attribute ["
+
REFRESH_CHECK_DELAY_ATTRIBUTE
+
"] with value '"
+
attributeValue
+
"': needs to be of type Number or String"
);
}
return
refreshCheckDelay
;
}
...
...
@@ -403,13 +408,15 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
boolean
proxyTargetClass
=
this
.
defaultProxyTargetClass
;
Object
attributeValue
=
beanDefinition
.
getAttribute
(
PROXY_TARGET_CLASS_ATTRIBUTE
);
if
(
attributeValue
instanceof
Boolean
)
{
proxyTargetClass
=
((
Boolean
)
attributeValue
).
booleanValue
();
}
else
if
(
attributeValue
instanceof
String
)
{
proxyTargetClass
=
new
Boolean
((
String
)
attributeValue
);
}
else
if
(
attributeValue
!=
null
)
{
throw
new
BeanDefinitionStoreException
(
"Invalid refresh check delay attribute ["
+
REFRESH_CHECK_DELAY_ATTRIBUTE
+
"] with value ["
+
attributeValue
+
"]: needs to be of type Number or String"
);
proxyTargetClass
=
(
Boolean
)
attributeValue
;
}
else
if
(
attributeValue
instanceof
String
)
{
proxyTargetClass
=
Boolean
.
valueOf
((
String
)
attributeValue
);
}
else
if
(
attributeValue
!=
null
)
{
throw
new
BeanDefinitionStoreException
(
"Invalid proxy target class attribute ["
+
PROXY_TARGET_CLASS_ATTRIBUTE
+
"] with value '"
+
attributeValue
+
"': needs to be of type Boolean or String"
);
}
return
proxyTargetClass
;
}
...
...
@@ -463,7 +470,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
if
(
scriptSourceLocator
.
startsWith
(
INLINE_SCRIPT_PREFIX
))
{
return
new
StaticScriptSource
(
scriptSourceLocator
.
substring
(
INLINE_SCRIPT_PREFIX
.
length
()),
beanName
);
}
else
{
}
else
{
return
new
ResourceScriptSource
(
resourceLoader
.
getResource
(
scriptSourceLocator
));
}
}
...
...
@@ -489,7 +497,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
String
propertyName
=
pv
.
getName
();
Class
<?>
propertyType
=
BeanUtils
.
findPropertyType
(
propertyName
,
interfaces
);
String
setterName
=
"set"
+
StringUtils
.
capitalize
(
propertyName
);
Signature
signature
=
new
Signature
(
setterName
,
Type
.
VOID_TYPE
,
new
Type
[]
{
Type
.
getType
(
propertyType
)
});
Signature
signature
=
new
Signature
(
setterName
,
Type
.
VOID_TYPE
,
new
Type
[]
{
Type
.
getType
(
propertyType
)
});
maker
.
add
(
signature
,
new
Type
[
0
]);
}
if
(
bd
instanceof
AbstractBeanDefinition
)
{
...
...
@@ -560,7 +568,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
}
proxyFactory
.
setInterfaces
(
interfaces
);
if
(
proxyTargetClass
)
{
classLoader
=
null
;
// F
orce use of Class.getClassLoader()
classLoader
=
null
;
// f
orce use of Class.getClassLoader()
proxyFactory
.
setProxyTargetClass
(
proxyTargetClass
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录