@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2013 the original author or authors .
* Copyright 2002 - 2016 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 .
@ -16,8 +16,8 @@
@@ -16,8 +16,8 @@
package org.springframework.scheduling.config ;
import org.springframework.beans.BeanWrapp er;
import org.springframework.beans.BeanWrapperImpl ;
import java.util.concurrent.RejectedExecutionHandl er;
import org.springframework.beans.factory.BeanNameAware ;
import org.springframework.beans.factory.DisposableBean ;
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 ;
/ * *
* FactoryBean for creating ThreadPoolTaskExecutor instances , choosing
* between the standard concurrent and the backport - concurrent variant .
* { @link FactoryBean } for creating { @link ThreadPoolTaskExecutor } instances ,
* primarily used behind the XML task namespace .
*
* @author Mark Fisher
* @author Juergen Hoeller
@ -41,13 +41,13 @@ public class TaskExecutorFactoryBean implements
@@ -41,13 +41,13 @@ public class TaskExecutorFactoryBean implements
private Integer queueCapacity ;
private Object rejectedExecutionHandler ;
private RejectedExecutionHandler rejectedExecutionHandler ;
private Integer keepAliveSeconds ;
private String beanName ;
private TaskExecutor target ;
private ThreadPoolT askExecutor target ;
public void setPoolSize ( String poolSize ) {
@ -58,7 +58,7 @@ public class TaskExecutorFactoryBean implements
@@ -58,7 +58,7 @@ public class TaskExecutorFactoryBean implements
this . queueCapacity = queueCapacity ;
}
public void setRejectedExecutionHandler ( Object rejectedExecutionHandler ) {
public void setRejectedExecutionHandler ( RejectedExecutionHandler rejectedExecutionHandler ) {
this . rejectedExecutionHandler = rejectedExecutionHandler ;
}
@ -73,28 +73,25 @@ public class TaskExecutorFactoryBean implements
@@ -73,28 +73,25 @@ public class TaskExecutorFactoryBean implements
@Override
public void afterPropertiesSet ( ) throws Exception {
BeanWrapper bw = new BeanWrapperImpl ( ThreadPoolTaskExecutor . class ) ;
determinePoolSizeRange ( bw ) ;
public void afterPropertiesSet ( ) {
this . target = new ThreadPoolTaskExecutor ( ) ;
determinePoolSizeRange ( ) ;
if ( this . queueCapacity ! = null ) {
bw . setPropertyValue ( "queueCapacity" , this . queueCapacity ) ;
this . target . setQueueCapacity ( this . queueCapacity ) ;
}
if ( this . keepAliveSeconds ! = null ) {
bw . setPropertyValue ( "keepAliveSeconds" , this . keepAliveSeconds ) ;
this . target . setKeepAliveSeconds ( this . keepAliveSeconds ) ;
}
if ( this . rejectedExecutionHandler ! = null ) {
bw . setPropertyValue ( "rejectedExecutionHandler" , this . rejectedExecutionHandler ) ;
this . target . setRejectedExecutionHandler ( this . rejectedExecutionHandler ) ;
}
if ( this . beanName ! = null ) {
bw . setPropertyValue ( "threadNamePrefix" , this . beanName + "-" ) ;
}
this . target = ( TaskExecutor ) bw . getWrappedInstance ( ) ;
if ( this . target instanceof InitializingBean ) {
( ( InitializingBean ) this . target ) . afterPropertiesSet ( ) ;
this . target . setThreadNamePrefix ( this . beanName + "-" ) ;
}
this . target . afterPropertiesSet ( ) ;
}
private void determinePoolSizeRange ( BeanWrapper bw ) {
private void determinePoolSizeRange ( ) {
if ( StringUtils . hasText ( this . poolSize ) ) {
try {
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" ) ;
}
if ( this . queueCapacity = = null ) {
// n o queue-capacity provided, so unbounded
// N o queue-capacity provided, so unbounded
if ( corePoolSize = = 0 ) {
// a ctually set 'corePoolSize' to the upper bound of the range
// but allow core threads to timeout
bw . setPropertyValue ( "allowCoreThreadTimeOut" , true ) ;
// A ctually set 'corePoolSize' to the upper bound of the range
// but allow core threads to timeout...
this . target . setAllowCoreThreadTimeOut ( true ) ;
corePoolSize = maxPoolSize ;
}
else {
// non-zero lower bound implies a core-max size range
// Non-zero lower bound implies a core-max size range...
throw new IllegalArgumentException (
"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 ;
maxPoolSize = value ;
}
bw . setPropertyValue ( "corePoolSize" , corePoolSize ) ;
bw . setPropertyValue ( "maxPoolSize" , maxPoolSize ) ;
this . target . setCorePoolSize ( corePoolSize ) ;
this . target . setMaxPoolSize ( maxPoolSize ) ;
}
catch ( NumberFormatException ex ) {
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
public void destroy ( ) throws Exception {
if ( this . target instanceof DisposableBean ) {
( ( DisposableBean ) this . target ) . destroy ( ) ;
}
public void destroy ( ) {
this . target . destroy ( ) ;
}
}