Added support for "taskExecutor" on the @Poller annotation. This requires a reference to a TaskExecutor instance resolvable by bean name (INT-409).

This commit is contained in:
Mark Fisher
2008-10-10 14:48:11 +00:00
parent 526f4b25dc
commit 0dfe9ca191
2 changed files with 10 additions and 0 deletions

View File

@@ -49,6 +49,8 @@ public @interface Poller {
int maxMessagesPerPoll() default -1;
String taskExecutor() default "";
Transactional transactionAttributes() default @Transactional;
String transactionManager() default "";

View File

@@ -22,6 +22,7 @@ import java.util.List;
import org.aopalliance.aop.Advice;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.annotation.Poller;
import org.springframework.integration.endpoint.AbstractPollingEndpoint;
import org.springframework.integration.scheduling.IntervalTrigger;
@@ -57,6 +58,13 @@ public abstract class AnnotationConfigUtils {
Transactional txAnnotation = pollerAnnotation.transactionAttributes();
endpoint.setTransactionDefinition(parseTransactionAnnotation(txAnnotation));
}
if (StringUtils.hasText(pollerAnnotation.taskExecutor())) {
String taskExecutorRef = pollerAnnotation.taskExecutor();
Assert.isTrue(beanFactory.containsBean(taskExecutorRef),
"failed to resolve taskExecutor reference, no such bean '" + taskExecutorRef + "'");
TaskExecutor taskExecutor = (TaskExecutor) beanFactory.getBean(taskExecutorRef, TaskExecutor.class);
endpoint.setTaskExecutor(taskExecutor);
}
String[] adviceChainArray = pollerAnnotation.adviceChain();
if (adviceChainArray.length > 0) {
List<Advice> adviceChain = new ArrayList<Advice>();