SPR-6644 The 'id' value from an 'executor' element in the task namespace is now used as the thread name prefix for the resulting ThreadPoolTaskExecutor instance.
This commit is contained in:
parent
265084cb6c
commit
4ab4fa7042
|
|
@ -108,6 +108,9 @@ public class TaskExecutorFactoryBean implements FactoryBean<TaskExecutor>, BeanN
|
||||||
this.setValueIfNotNull("corePoolSize", range[0]);
|
this.setValueIfNotNull("corePoolSize", range[0]);
|
||||||
this.setValueIfNotNull("maxPoolSize", range[1]);
|
this.setValueIfNotNull("maxPoolSize", range[1]);
|
||||||
}
|
}
|
||||||
|
if (this.beanName != null) {
|
||||||
|
this.beanWrapper.setPropertyValue("threadNamePrefix", this.beanName + "-");
|
||||||
|
}
|
||||||
this.target = (TaskExecutor) this.beanWrapper.getWrappedInstance();
|
this.target = (TaskExecutor) this.beanWrapper.getWrappedInstance();
|
||||||
if (this.target instanceof InitializingBean) {
|
if (this.target instanceof InitializingBean) {
|
||||||
((InitializingBean)this.target).afterPropertiesSet();
|
((InitializingBean)this.target).afterPropertiesSet();
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package org.springframework.scheduling.config;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
@ -30,6 +29,7 @@ import org.springframework.beans.factory.BeanCreationException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
import org.springframework.util.CustomizableThreadCreator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
|
|
@ -124,6 +124,12 @@ public class ExecutorBeanDefinitionParserTests {
|
||||||
this.context.getBean("propertyPlaceholderWithInvalidPoolSize");
|
this.context.getBean("propertyPlaceholderWithInvalidPoolSize");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void threadNamePrefix() {
|
||||||
|
CustomizableThreadCreator executor = this.context.getBean("default", CustomizableThreadCreator.class);
|
||||||
|
assertEquals("default-", executor.getThreadNamePrefix());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private int getCorePoolSize(Object executor) {
|
private int getCorePoolSize(Object executor) {
|
||||||
return (Integer) new DirectFieldAccessor(executor).getPropertyValue("corePoolSize");
|
return (Integer) new DirectFieldAccessor(executor).getPropertyValue("corePoolSize");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue