diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/channel/ExecutorChannel.java b/org.springframework.integration/src/main/java/org/springframework/integration/channel/ExecutorChannel.java index bfd510acce..cca5d68b6b 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/channel/ExecutorChannel.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/channel/ExecutorChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 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,9 +16,10 @@ package org.springframework.integration.channel; +import java.util.concurrent.Executor; + import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.core.task.TaskExecutor; import org.springframework.integration.core.MessageChannel; import org.springframework.integration.dispatcher.LoadBalancingStrategy; import org.springframework.integration.dispatcher.UnicastingDispatcher; @@ -29,11 +30,11 @@ import org.springframework.util.ErrorHandler; /** * An implementation of {@link MessageChannel} that delegates to an instance of * {@link UnicastingDispatcher} which in turn delegates all dispatching - * invocations to a {@link TaskExecutor}. + * invocations to an {@link Executor}. *
*
- * The TaskExecutor must not be null. + * The Executor must not be null. */ - public ExecutorChannel(TaskExecutor taskExecutor) { - this(taskExecutor, null); + public ExecutorChannel(Executor executor) { + this(executor, null); } /** * Create an ExecutorChannel with a {@link LoadBalancingStrategy} that - * delegates to the provided {@link TaskExecutor} when dispatching Messages. + * delegates to the provided {@link Executor} when dispatching Messages. *
- * The TaskExecutor must not be null.
+ * The Executor must not be null.
*/
- public ExecutorChannel(TaskExecutor taskExecutor, LoadBalancingStrategy loadBalancingStrategy) {
- Assert.notNull(taskExecutor, "taskExecutor must not be null");
- this.taskExecutor = taskExecutor;
- this.dispatcher = new UnicastingDispatcher(taskExecutor);
+ public ExecutorChannel(Executor executor, LoadBalancingStrategy loadBalancingStrategy) {
+ Assert.notNull(executor, "executor must not be null");
+ this.executor = executor;
+ this.dispatcher = new UnicastingDispatcher(executor);
if (loadBalancingStrategy != null) {
this.loadBalancingStrategy = loadBalancingStrategy;
this.dispatcher.setLoadBalancingStrategy(loadBalancingStrategy);
@@ -94,11 +95,11 @@ public class ExecutorChannel extends AbstractSubscribableChannel implements Bean
}
public void setBeanFactory(BeanFactory beanFactory) {
- if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor)) {
+ if (!(this.executor instanceof ErrorHandlingTaskExecutor)) {
ErrorHandler errorHandler = new MessagePublishingErrorHandler(new BeanFactoryChannelResolver(beanFactory));
- this.taskExecutor = new ErrorHandlingTaskExecutor(this.taskExecutor, errorHandler);
+ this.executor = new ErrorHandlingTaskExecutor(this.executor, errorHandler);
}
- this.dispatcher = new UnicastingDispatcher(this.taskExecutor);
+ this.dispatcher = new UnicastingDispatcher(this.executor);
this.dispatcher.setFailover(this.failover);
if (this.loadBalancingStrategy != null) {
this.dispatcher.setLoadBalancingStrategy(this.loadBalancingStrategy);
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/channel/PublishSubscribeChannel.java b/org.springframework.integration/src/main/java/org/springframework/integration/channel/PublishSubscribeChannel.java
index 3e0869c641..931a6c4550 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/channel/PublishSubscribeChannel.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/channel/PublishSubscribeChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 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,9 +16,10 @@
package org.springframework.integration.channel;
+import java.util.concurrent.Executor;
+
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.dispatcher.BroadcastingDispatcher;
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
import org.springframework.util.ErrorHandler;
@@ -32,7 +33,7 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel impleme
private volatile BroadcastingDispatcher dispatcher;
- private volatile TaskExecutor taskExecutor;
+ private volatile Executor executor;
private volatile ErrorHandler errorHandler;
@@ -42,13 +43,13 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel impleme
/**
- * Create a PublishSubscribeChannel that will use a {@link TaskExecutor}
+ * Create a PublishSubscribeChannel that will use an {@link Executor}
* to invoke the handlers. If this is null, each invocation will occur in
* the message sender's thread.
*/
- public PublishSubscribeChannel(TaskExecutor taskExecutor) {
- this.taskExecutor = taskExecutor;
- this.dispatcher = new BroadcastingDispatcher(taskExecutor);
+ public PublishSubscribeChannel(Executor executor) {
+ this.executor = executor;
+ this.dispatcher = new BroadcastingDispatcher(executor);
}
/**
@@ -63,14 +64,14 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel impleme
/**
* Provide an {@link ErrorHandler} strategy for handling Exceptions that
* occur downstream from this channel. This will only be applied if
- * a TaskExecutor has been configured to dispatch the Messages for this
+ * an Executor has been configured to dispatch the Messages for this
* channel. Otherwise, Exceptions will be thrown directly within the
* sending Thread. If no ErrorHandler is provided, and this channel does
- * delegate its dispatching to a TaskExecutor, the default strategy is
+ * delegate its dispatching to an Executor, the default strategy is
* a {@link MessagePublishingErrorHandler} that sends error messages to
* the failed request Message's error channel header if available or to
* the default 'errorChannel' otherwise.
- * @see #PublishSubscribeChannel(TaskExecutor)
+ * @see #PublishSubscribeChannel(Executor)
*/
public void setErrorHandler(ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
@@ -104,14 +105,14 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel impleme
* Callback method for the {@link BeanFactoryAware} interface.
*/
public void setBeanFactory(BeanFactory beanFactory) {
- if (this.taskExecutor != null) {
- if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor)) {
+ if (this.executor != null) {
+ if (!(this.executor instanceof ErrorHandlingTaskExecutor)) {
if (this.errorHandler == null) {
this.errorHandler = new MessagePublishingErrorHandler(new BeanFactoryChannelResolver(beanFactory));
}
- this.taskExecutor = new ErrorHandlingTaskExecutor(this.taskExecutor, this.errorHandler);
+ this.executor = new ErrorHandlingTaskExecutor(this.executor, this.errorHandler);
}
- this.dispatcher = new BroadcastingDispatcher(this.taskExecutor);
+ this.dispatcher = new BroadcastingDispatcher(this.executor);
this.dispatcher.setIgnoreFailures(this.ignoreFailures);
this.dispatcher.setApplySequence(this.applySequence);
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java
index 12752b7c17..ca48a437f7 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -18,8 +18,8 @@ package org.springframework.integration.dispatcher;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.Executor;
-import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageHeaders;
import org.springframework.integration.message.MessageBuilder;
@@ -29,7 +29,7 @@ import org.springframework.integration.message.MessageHandler;
* A broadcasting dispatcher implementation. If the 'ignoreFailures' property
* is set to false (the default), it will fail fast such that any
* Exception thrown by a MessageHandler may prevent subsequent handlers from
- * receiving the Message. However, when a TaskExecutor is provided, the Messages
+ * receiving the Message. However, when an Executor is provided, the Messages
* may be dispatched in separate Threads so that other handlers are invoked even
* when the 'ignoreFailures' flag is false.
*
@@ -48,15 +48,15 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
private volatile boolean applySequence;
- private final TaskExecutor taskExecutor;
+ private final Executor executor;
public BroadcastingDispatcher() {
- this.taskExecutor = null;
+ this.executor = null;
}
- public BroadcastingDispatcher(TaskExecutor taskExecutor) {
- this.taskExecutor = taskExecutor;
+ public BroadcastingDispatcher(Executor executor) {
+ this.executor = executor;
}
@@ -66,11 +66,11 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
* Exception will be thrown when a handler fails. To override this and
* suppress Exceptions, set the value to true.
*
- * Keep in mind that when using a TaskExecutor, even without ignoring the
+ * Keep in mind that when using an Executor, even without ignoring the
* failures, other handlers may be invoked after one throws an Exception.
- * Since the TaskExecutor is using a different thread, this flag will only
- * affect whether an error Message is sent to the error channel or not in
- * the case that a TaskExecutor has been configured.
+ * Since the Executor is most likely using a different thread, this flag would
+ * only affect whether an error Message is sent to the error channel or not in
+ * the case that such an Executor has been configured.
*/
public void setIgnoreFailures(boolean ignoreFailures) {
this.ignoreFailures = ignoreFailures;
@@ -98,8 +98,8 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
.setCorrelationId(message.getHeaders().getId())
.setHeader(MessageHeaders.ID, UUID.randomUUID())
.build();
- if (this.taskExecutor != null) {
- this.taskExecutor.execute(new Runnable() {
+ if (this.executor != null) {
+ this.executor.execute(new Runnable() {
public void run() {
invokeHandler(handler, messageToSend);
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/UnicastingDispatcher.java b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/UnicastingDispatcher.java
index 482af6625a..7720892300 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/UnicastingDispatcher.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/UnicastingDispatcher.java
@@ -1,4 +1,4 @@
-/* Copyright 2002-2009 the original author or authors.
+/* Copyright 2002-2010 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.
@@ -18,8 +18,8 @@ package org.springframework.integration.dispatcher;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.Executor;
-import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.core.Message;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessageHandler;
@@ -49,15 +49,15 @@ public class UnicastingDispatcher extends AbstractDispatcher {
private volatile LoadBalancingStrategy loadBalancingStrategy;
- private final TaskExecutor taskExecutor;
+ private final Executor executor;
public UnicastingDispatcher() {
- this.taskExecutor = null;
+ this.executor = null;
}
- public UnicastingDispatcher(TaskExecutor taskExecutor) {
- this.taskExecutor = taskExecutor;
+ public UnicastingDispatcher(Executor executor) {
+ this.executor = executor;
}
@@ -79,8 +79,8 @@ public class UnicastingDispatcher extends AbstractDispatcher {
}
public final boolean dispatch(final Message> message) {
- if (this.taskExecutor != null) {
- this.taskExecutor.execute(new Runnable() {
+ if (this.executor != null) {
+ this.executor.execute(new Runnable() {
public void run() {
doDispatch(message);
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java
index 753993ddd0..a08d32a300 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -18,13 +18,13 @@ package org.springframework.integration.endpoint;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledFuture;
import org.aopalliance.aop.Advice;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.channel.BeanFactoryChannelResolver;
import org.springframework.integration.channel.MessagePublishingErrorHandler;
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
@@ -51,7 +51,7 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
protected volatile long maxMessagesPerPoll = MAX_MESSAGES_UNBOUNDED;
- private volatile TaskExecutor taskExecutor;
+ private volatile Executor taskExecutor;
private volatile ErrorHandler errorHandler;
@@ -96,7 +96,7 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
this.maxMessagesPerPoll = maxMessagesPerPoll;
}
- public void setTaskExecutor(TaskExecutor taskExecutor) {
+ public void setTaskExecutor(Executor taskExecutor) {
this.taskExecutor = taskExecutor;
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/scheduling/PollerMetadata.java b/org.springframework.integration/src/main/java/org/springframework/integration/scheduling/PollerMetadata.java
index ca0e0f364a..643ce1f8b1 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/scheduling/PollerMetadata.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/scheduling/PollerMetadata.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -17,9 +17,9 @@
package org.springframework.integration.scheduling;
import java.util.List;
+import java.util.concurrent.Executor;
import org.aopalliance.aop.Advice;
-import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.Trigger;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
@@ -37,7 +37,7 @@ public class PollerMetadata {
private List