Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
157dcab5
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,发现更多精彩内容 >>
提交
157dcab5
编写于
4月 07, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup of remaining direct BeanWrapper usage
Issue: SPR-14121
上级
5c1d3fca
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
50 deletion
+44
-50
spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java
.../src/main/java/org/springframework/beans/BeanWrapper.java
+14
-12
spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java
...ringframework/scheduling/quartz/SpringBeanJobFactory.java
+3
-3
spring-context/src/main/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParser.java
...ework/scheduling/config/ExecutorBeanDefinitionParser.java
+1
-4
spring-context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java
...gframework/scheduling/config/TaskExecutorFactoryBean.java
+26
-31
未找到文件。
spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java
浏览文件 @
157dcab5
/*
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -48,6 +48,19 @@ import java.beans.PropertyDescriptor;
...
@@ -48,6 +48,19 @@ import java.beans.PropertyDescriptor;
*/
*/
public
interface
BeanWrapper
extends
ConfigurablePropertyAccessor
{
public
interface
BeanWrapper
extends
ConfigurablePropertyAccessor
{
/**
* Specify a limit for array and collection auto-growing.
* <p>Default is unlimited on a plain BeanWrapper.
* @since 4.1
*/
void
setAutoGrowCollectionLimit
(
int
autoGrowCollectionLimit
);
/**
* Return the limit for array and collection auto-growing.
* @since 4.1
*/
int
getAutoGrowCollectionLimit
();
/**
/**
* Return the bean instance wrapped by this object, if any.
* Return the bean instance wrapped by this object, if any.
* @return the bean instance, or {@code null} if none set
* @return the bean instance, or {@code null} if none set
...
@@ -78,15 +91,4 @@ public interface BeanWrapper extends ConfigurablePropertyAccessor {
...
@@ -78,15 +91,4 @@ public interface BeanWrapper extends ConfigurablePropertyAccessor {
*/
*/
PropertyDescriptor
getPropertyDescriptor
(
String
propertyName
)
throws
InvalidPropertyException
;
PropertyDescriptor
getPropertyDescriptor
(
String
propertyName
)
throws
InvalidPropertyException
;
/**
* Specify a limit for array and collection auto-growing.
* <p>Default is unlimited on a plain BeanWrapper.
*/
void
setAutoGrowCollectionLimit
(
int
autoGrowCollectionLimit
);
/**
* Return the limit for array and collection auto-growing.
*/
int
getAutoGrowCollectionLimit
();
}
}
spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java
浏览文件 @
157dcab5
/*
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -72,8 +72,8 @@ public class SpringBeanJobFactory extends AdaptableJobFactory implements Schedul
...
@@ -72,8 +72,8 @@ public class SpringBeanJobFactory extends AdaptableJobFactory implements Schedul
@Override
@Override
protected
Object
createJobInstance
(
TriggerFiredBundle
bundle
)
throws
Exception
{
protected
Object
createJobInstance
(
TriggerFiredBundle
bundle
)
throws
Exception
{
Object
job
=
super
.
createJobInstance
(
bundle
);
Object
job
=
super
.
createJobInstance
(
bundle
);
BeanWrapper
bw
=
PropertyAccessorFactory
.
forBeanPropertyAccess
(
job
);
if
(
isEligibleForPropertyPopulation
(
job
))
{
if
(
isEligibleForPropertyPopulation
(
bw
.
getWrappedInstance
()))
{
BeanWrapper
bw
=
PropertyAccessorFactory
.
forBeanPropertyAccess
(
job
);
MutablePropertyValues
pvs
=
new
MutablePropertyValues
();
MutablePropertyValues
pvs
=
new
MutablePropertyValues
();
if
(
this
.
schedulerContext
!=
null
)
{
if
(
this
.
schedulerContext
!=
null
)
{
pvs
.
addPropertyValues
(
this
.
schedulerContext
);
pvs
.
addPropertyValues
(
this
.
schedulerContext
);
...
...
spring-context/src/main/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParser.java
浏览文件 @
157dcab5
/*
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
16
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -61,9 +61,6 @@ public class ExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionPa
...
@@ -61,9 +61,6 @@ public class ExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionPa
return
;
return
;
}
}
String
prefix
=
"java.util.concurrent.ThreadPoolExecutor."
;
String
prefix
=
"java.util.concurrent.ThreadPoolExecutor."
;
if
(
builder
.
getRawBeanDefinition
().
getBeanClassName
().
contains
(
"backport"
))
{
prefix
=
"edu.emory.mathcs.backport."
+
prefix
;
}
String
policyClassName
;
String
policyClassName
;
if
(
rejectionPolicy
.
equals
(
"ABORT"
))
{
if
(
rejectionPolicy
.
equals
(
"ABORT"
))
{
policyClassName
=
prefix
+
"AbortPolicy"
;
policyClassName
=
prefix
+
"AbortPolicy"
;
...
...
spring-context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java
浏览文件 @
157dcab5
/*
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,8 +16,8 @@
...
@@ -16,8 +16,8 @@
package
org.springframework.scheduling.config
;
package
org.springframework.scheduling.config
;
import
org.springframework.beans.BeanWrapp
er
;
import
java.util.concurrent.RejectedExecutionHandl
er
;
import
org.springframework.beans.BeanWrapperImpl
;
import
org.springframework.beans.factory.BeanNameAware
;
import
org.springframework.beans.factory.BeanNameAware
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.FactoryBean
;
import
org.springframework.beans.factory.FactoryBean
;
...
@@ -27,8 +27,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
...
@@ -27,8 +27,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
/**
/**
*
FactoryBean for creating ThreadPoolTaskExecutor instances, choosing
*
{@link FactoryBean} for creating {@link ThreadPoolTaskExecutor} instances,
*
between the standard concurrent and the backport-concurrent variant
.
*
primarily used behind the XML task namespace
.
*
*
* @author Mark Fisher
* @author Mark Fisher
* @author Juergen Hoeller
* @author Juergen Hoeller
...
@@ -41,13 +41,13 @@ public class TaskExecutorFactoryBean implements
...
@@ -41,13 +41,13 @@ public class TaskExecutorFactoryBean implements
private
Integer
queueCapacity
;
private
Integer
queueCapacity
;
private
Object
rejectedExecutionHandler
;
private
RejectedExecutionHandler
rejectedExecutionHandler
;
private
Integer
keepAliveSeconds
;
private
Integer
keepAliveSeconds
;
private
String
beanName
;
private
String
beanName
;
private
TaskExecutor
target
;
private
T
hreadPoolT
askExecutor
target
;
public
void
setPoolSize
(
String
poolSize
)
{
public
void
setPoolSize
(
String
poolSize
)
{
...
@@ -58,7 +58,7 @@ public class TaskExecutorFactoryBean implements
...
@@ -58,7 +58,7 @@ public class TaskExecutorFactoryBean implements
this
.
queueCapacity
=
queueCapacity
;
this
.
queueCapacity
=
queueCapacity
;
}
}
public
void
setRejectedExecutionHandler
(
Object
rejectedExecutionHandler
)
{
public
void
setRejectedExecutionHandler
(
RejectedExecutionHandler
rejectedExecutionHandler
)
{
this
.
rejectedExecutionHandler
=
rejectedExecutionHandler
;
this
.
rejectedExecutionHandler
=
rejectedExecutionHandler
;
}
}
...
@@ -73,28 +73,25 @@ public class TaskExecutorFactoryBean implements
...
@@ -73,28 +73,25 @@ public class TaskExecutorFactoryBean implements
@Override
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
public
void
afterPropertiesSet
()
{
BeanWrapper
bw
=
new
BeanWrapperImpl
(
ThreadPoolTaskExecutor
.
class
);
this
.
target
=
new
ThreadPoolTaskExecutor
(
);
determinePoolSizeRange
(
bw
);
determinePoolSizeRange
();
if
(
this
.
queueCapacity
!=
null
)
{
if
(
this
.
queueCapacity
!=
null
)
{
bw
.
setPropertyValue
(
"queueCapacity"
,
this
.
queueCapacity
);
this
.
target
.
setQueueCapacity
(
this
.
queueCapacity
);
}
}
if
(
this
.
keepAliveSeconds
!=
null
)
{
if
(
this
.
keepAliveSeconds
!=
null
)
{
bw
.
setPropertyValue
(
"keepAliveSeconds"
,
this
.
keepAliveSeconds
);
this
.
target
.
setKeepAliveSeconds
(
this
.
keepAliveSeconds
);
}
}
if
(
this
.
rejectedExecutionHandler
!=
null
)
{
if
(
this
.
rejectedExecutionHandler
!=
null
)
{
bw
.
setPropertyValue
(
"rejectedExecutionHandler"
,
this
.
rejectedExecutionHandler
);
this
.
target
.
setRejectedExecutionHandler
(
this
.
rejectedExecutionHandler
);
}
}
if
(
this
.
beanName
!=
null
)
{
if
(
this
.
beanName
!=
null
)
{
bw
.
setPropertyValue
(
"threadNamePrefix"
,
this
.
beanName
+
"-"
);
this
.
target
.
setThreadNamePrefix
(
this
.
beanName
+
"-"
);
}
this
.
target
=
(
TaskExecutor
)
bw
.
getWrappedInstance
();
if
(
this
.
target
instanceof
InitializingBean
)
{
((
InitializingBean
)
this
.
target
).
afterPropertiesSet
();
}
}
this
.
target
.
afterPropertiesSet
();
}
}
private
void
determinePoolSizeRange
(
BeanWrapper
bw
)
{
private
void
determinePoolSizeRange
()
{
if
(
StringUtils
.
hasText
(
this
.
poolSize
))
{
if
(
StringUtils
.
hasText
(
this
.
poolSize
))
{
try
{
try
{
int
corePoolSize
;
int
corePoolSize
;
...
@@ -108,15 +105,15 @@ public class TaskExecutorFactoryBean implements
...
@@ -108,15 +105,15 @@ public class TaskExecutorFactoryBean implements
"Lower bound of pool-size range must not exceed the upper bound"
);
"Lower bound of pool-size range must not exceed the upper bound"
);
}
}
if
(
this
.
queueCapacity
==
null
)
{
if
(
this
.
queueCapacity
==
null
)
{
//
n
o queue-capacity provided, so unbounded
//
N
o queue-capacity provided, so unbounded
if
(
corePoolSize
==
0
)
{
if
(
corePoolSize
==
0
)
{
//
a
ctually set 'corePoolSize' to the upper bound of the range
//
A
ctually set 'corePoolSize' to the upper bound of the range
// but allow core threads to timeout
// but allow core threads to timeout
...
bw
.
setPropertyValue
(
"allowCoreThreadTimeOut"
,
true
);
this
.
target
.
setAllowCoreThreadTimeOut
(
true
);
corePoolSize
=
maxPoolSize
;
corePoolSize
=
maxPoolSize
;
}
}
else
{
else
{
//
non-zero lower bound implies a core-max size range
//
Non-zero lower bound implies a core-max size range...
throw
new
IllegalArgumentException
(
throw
new
IllegalArgumentException
(
"A non-zero lower bound for the size range requires a queue-capacity value"
);
"A non-zero lower bound for the size range requires a queue-capacity value"
);
}
}
...
@@ -127,8 +124,8 @@ public class TaskExecutorFactoryBean implements
...
@@ -127,8 +124,8 @@ public class TaskExecutorFactoryBean implements
corePoolSize
=
value
;
corePoolSize
=
value
;
maxPoolSize
=
value
;
maxPoolSize
=
value
;
}
}
bw
.
setPropertyValue
(
"corePoolSize"
,
corePoolSize
);
this
.
target
.
setCorePoolSize
(
corePoolSize
);
bw
.
setPropertyValue
(
"maxPoolSize"
,
maxPoolSize
);
this
.
target
.
setMaxPoolSize
(
maxPoolSize
);
}
}
catch
(
NumberFormatException
ex
)
{
catch
(
NumberFormatException
ex
)
{
throw
new
IllegalArgumentException
(
"Invalid pool-size value ["
+
this
.
poolSize
+
"]: only single "
+
throw
new
IllegalArgumentException
(
"Invalid pool-size value ["
+
this
.
poolSize
+
"]: only single "
+
...
@@ -155,10 +152,8 @@ public class TaskExecutorFactoryBean implements
...
@@ -155,10 +152,8 @@ public class TaskExecutorFactoryBean implements
@Override
@Override
public
void
destroy
()
throws
Exception
{
public
void
destroy
()
{
if
(
this
.
target
instanceof
DisposableBean
)
{
this
.
target
.
destroy
();
((
DisposableBean
)
this
.
target
).
destroy
();
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录