Browse Source

RESOLVED - issue SPR-6444: TaskExecutor not initialized in task namespace

pull/23217/head
David Syer 15 years ago
parent
commit
e10161182b
  1. 4
      org.springframework.context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java
  2. 14
      org.springframework.context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java

4
org.springframework.context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java

@ -21,6 +21,7 @@ import org.springframework.beans.BeanWrapperImpl; @@ -21,6 +21,7 @@ import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.JdkVersion;
import org.springframework.core.task.TaskExecutor;
import org.springframework.util.Assert;
@ -108,6 +109,9 @@ public class TaskExecutorFactoryBean implements FactoryBean<TaskExecutor>, BeanN @@ -108,6 +109,9 @@ public class TaskExecutorFactoryBean implements FactoryBean<TaskExecutor>, BeanN
this.setValueIfNotNull("maxPoolSize", range[1]);
}
this.target = (TaskExecutor) this.beanWrapper.getWrappedInstance();
if (this.target instanceof InitializingBean) {
((InitializingBean)this.target).afterPropertiesSet();
}
}
}

14
org.springframework.context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java

@ -18,6 +18,10 @@ package org.springframework.scheduling.config; @@ -18,6 +18,10 @@ package org.springframework.scheduling.config;
import static org.junit.Assert.assertEquals;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import org.junit.Before;
import org.junit.Test;
@ -25,6 +29,7 @@ import org.springframework.beans.DirectFieldAccessor; @@ -25,6 +29,7 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
* @author Mark Fisher
@ -41,13 +46,20 @@ public class ExecutorBeanDefinitionParserTests { @@ -41,13 +46,20 @@ public class ExecutorBeanDefinitionParserTests {
}
@Test
public void defaultExecutor() {
public void defaultExecutor() throws Exception {
Object executor = this.context.getBean("default");
assertEquals(1, this.getCorePoolSize(executor));
assertEquals(Integer.MAX_VALUE, this.getMaxPoolSize(executor));
assertEquals(Integer.MAX_VALUE, this.getQueueCapacity(executor));
assertEquals(60, this.getKeepAliveSeconds(executor));
assertEquals(false, this.getAllowCoreThreadTimeOut(executor));
FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
public String call() throws Exception {
return "foo";
}
});
((ThreadPoolTaskExecutor)executor).execute(task);
assertEquals("foo", task.get());
}
@Test

Loading…
Cancel
Save