diff --git a/org.springframework.integration.adapter/.classpath b/org.springframework.integration.adapter/.classpath
index 71d3a93ba0..9b7f049986 100644
--- a/org.springframework.integration.adapter/.classpath
+++ b/org.springframework.integration.adapter/.classpath
@@ -7,11 +7,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/org.springframework.integration.event/.classpath b/org.springframework.integration.event/.classpath
index 71d3a93ba0..9b7f049986 100644
--- a/org.springframework.integration.event/.classpath
+++ b/org.springframework.integration.event/.classpath
@@ -7,11 +7,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/org.springframework.integration.event/src/main/java/org/springframework/integration/event/ApplicationEventInboundChannelAdapter.java b/org.springframework.integration.event/src/main/java/org/springframework/integration/event/ApplicationEventInboundChannelAdapter.java
index 174399626d..a47372f4ff 100644
--- a/org.springframework.integration.event/src/main/java/org/springframework/integration/event/ApplicationEventInboundChannelAdapter.java
+++ b/org.springframework.integration.event/src/main/java/org/springframework/integration/event/ApplicationEventInboundChannelAdapter.java
@@ -51,7 +51,6 @@ public class ApplicationEventInboundChannelAdapter extends MessageProducerSuppor
}
public void onApplicationEvent(ApplicationEvent event) {
- super.onApplicationEvent(event);
if (CollectionUtils.isEmpty(this.eventTypes)) {
this.sendEventAsMessage(event);
return;
diff --git a/org.springframework.integration.file/.classpath b/org.springframework.integration.file/.classpath
index 19a7952e68..98e54451d2 100644
--- a/org.springframework.integration.file/.classpath
+++ b/org.springframework.integration.file/.classpath
@@ -7,12 +7,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithPatternParserTests.java b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithPatternParserTests.java
index aed0693e16..a3e3086c37 100644
--- a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithPatternParserTests.java
+++ b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterWithPatternParserTests.java
@@ -34,7 +34,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.endpoint.AbstractEndpoint;
-import org.springframework.integration.endpoint.AbstractEndpoint.StartupMode;
import org.springframework.integration.file.AcceptOnceFileListFilter;
import org.springframework.integration.file.CompositeFileListFilter;
import org.springframework.integration.file.FileListFilter;
@@ -74,7 +73,7 @@ public class FileInboundChannelAdapterWithPatternParserTests {
@Test
public void autoStartupDisabled() {
assertFalse(this.endpoint.isRunning());
- assertEquals(StartupMode.MANUAL, new DirectFieldAccessor(endpoint).getPropertyValue("startupMode"));
+ assertEquals(Boolean.FALSE, new DirectFieldAccessor(endpoint).getPropertyValue("autoStartup"));
}
@Test
diff --git a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileOutboundChannelAdapterParserTests.java b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileOutboundChannelAdapterParserTests.java
index fe65450642..d9ad985193 100644
--- a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileOutboundChannelAdapterParserTests.java
+++ b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileOutboundChannelAdapterParserTests.java
@@ -28,7 +28,6 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.endpoint.EventDrivenConsumer;
-import org.springframework.integration.endpoint.AbstractEndpoint.StartupMode;
import org.springframework.integration.file.DefaultFileNameGenerator;
import org.springframework.integration.file.FileWritingMessageHandler;
import org.springframework.test.context.ContextConfiguration;
@@ -105,7 +104,7 @@ public class FileOutboundChannelAdapterParserTests {
@Test
public void adapterWithAutoStartupFalse() {
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapterWithOrder);
- assertEquals(StartupMode.MANUAL, adapterAccessor.getPropertyValue("startupMode"));
+ assertEquals(Boolean.FALSE, adapterAccessor.getPropertyValue("autoStartup"));
}
}
diff --git a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileOutboundGatewayParserTests.java b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileOutboundGatewayParserTests.java
index c07f6c0850..574176a00c 100644
--- a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileOutboundGatewayParserTests.java
+++ b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/config/FileOutboundGatewayParserTests.java
@@ -24,7 +24,6 @@ import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
-import org.springframework.integration.endpoint.AbstractEndpoint.StartupMode;
import org.springframework.integration.file.FileWritingMessageHandler;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -46,7 +45,7 @@ public class FileOutboundGatewayParserTests {
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
FileWritingMessageHandler handler = (FileWritingMessageHandler)
gatewayAccessor.getPropertyValue("handler");
- assertEquals(StartupMode.MANUAL, gatewayAccessor.getPropertyValue("startupMode"));
+ assertEquals(Boolean.FALSE, gatewayAccessor.getPropertyValue("autoStartup"));
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
assertEquals(777, handlerAccessor.getPropertyValue("order"));
}
diff --git a/org.springframework.integration.http/.classpath b/org.springframework.integration.http/.classpath
index bdebd6c502..4eff577d6a 100644
--- a/org.springframework.integration.http/.classpath
+++ b/org.springframework.integration.http/.classpath
@@ -11,14 +11,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/org.springframework.integration.http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests.java b/org.springframework.integration.http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests.java
index bf8fcad7f0..a5e2b97040 100644
--- a/org.springframework.integration.http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests.java
+++ b/org.springframework.integration.http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests.java
@@ -33,7 +33,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.endpoint.AbstractEndpoint;
-import org.springframework.integration.endpoint.AbstractEndpoint.StartupMode;
import org.springframework.integration.http.DefaultOutboundRequestMapper;
import org.springframework.integration.http.HttpOutboundEndpoint;
import org.springframework.integration.http.HttpRequestExecutor;
@@ -93,7 +92,7 @@ public class HttpOutboundGatewayParserTests {
assertEquals(this.applicationContext.getBean("requests"), requestChannel);
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(77, accessor.getPropertyValue("order"));
- assertEquals(StartupMode.MANUAL, endpointAccessor.getPropertyValue("startupMode"));
+ assertEquals(Boolean.FALSE, endpointAccessor.getPropertyValue("autoStartup"));
Object replyChannel = accessor.getPropertyValue("outputChannel");
assertNotNull(replyChannel);
assertEquals(this.applicationContext.getBean("replies"), replyChannel);
diff --git a/org.springframework.integration.httpinvoker/.classpath b/org.springframework.integration.httpinvoker/.classpath
index 14a7ffb836..dd977550fc 100644
--- a/org.springframework.integration.httpinvoker/.classpath
+++ b/org.springframework.integration.httpinvoker/.classpath
@@ -9,14 +9,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/org.springframework.integration.jms/.classpath b/org.springframework.integration.jms/.classpath
index 8c65e904d3..2437fa1273 100644
--- a/org.springframework.integration.jms/.classpath
+++ b/org.springframework.integration.jms/.classpath
@@ -10,14 +10,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsDestinationBackedMessageChannel.java b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsDestinationBackedMessageChannel.java
index cf86c9cd75..92701fba18 100644
--- a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsDestinationBackedMessageChannel.java
+++ b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsDestinationBackedMessageChannel.java
@@ -23,6 +23,7 @@ import javax.jms.Topic;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.SmartLifecycle;
import org.springframework.integration.channel.SubscribableChannel;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
@@ -52,8 +53,8 @@ import org.springframework.util.Assert;
* @author Mark Fisher
* @since 2.0
*/
-public class JmsDestinationBackedMessageChannel implements
- SubscribableChannel, MessageListener, BeanNameAware, InitializingBean {
+public class JmsDestinationBackedMessageChannel implements SubscribableChannel, MessageListener,
+ BeanNameAware, SmartLifecycle, InitializingBean {
private final JmsTemplate jmsTemplate = new JmsTemplate();
@@ -158,4 +159,30 @@ public class JmsDestinationBackedMessageChannel implements
}
}
+ // SmartLifecycle implementation (delegates to the MessageListener container)
+
+ public int getPhase() {
+ return this.container.getPhase();
+ }
+
+ public boolean isAutoStartup() {
+ return this.container.isAutoStartup();
+ }
+
+ public boolean isRunning() {
+ return this.container.isRunning();
+ }
+
+ public void start() {
+ this.container.start();
+ }
+
+ public void stop() {
+ this.container.stop();
+ }
+
+ public void stop(Runnable callback) {
+ this.container.stop(callback);
+ }
+
}
diff --git a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsMessageDrivenEndpoint.java b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsMessageDrivenEndpoint.java
index da2c101ad3..2e583dfc3a 100644
--- a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsMessageDrivenEndpoint.java
+++ b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsMessageDrivenEndpoint.java
@@ -33,8 +33,6 @@ public class JmsMessageDrivenEndpoint extends AbstractEndpoint implements Dispos
private final ChannelPublishingJmsMessageListener listener;
- private volatile boolean autoStartup = true;
-
public JmsMessageDrivenEndpoint(AbstractMessageListenerContainer listenerContainer, ChannelPublishingJmsMessageListener listener) {
Assert.notNull(listenerContainer, "listener container must not be null");
@@ -45,18 +43,8 @@ public class JmsMessageDrivenEndpoint extends AbstractEndpoint implements Dispos
}
- public void setAutoStartup(boolean autoStartup) {
- this.autoStartup = autoStartup;
- }
-
@Override
protected void onInit() throws Exception {
- if (this.autoStartup) {
- this.setStartupMode(StartupMode.ON_CONTEXT_REFRESH);
- }
- else {
- this.setStartupMode(StartupMode.MANUAL);
- }
this.listener.afterPropertiesSet();
if (!this.listenerContainer.isActive()) {
this.listenerContainer.afterPropertiesSet();
diff --git a/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/JmsDestinationBackedMessageChannelTests.java b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/JmsDestinationBackedMessageChannelTests.java
index 74233bae46..04c7444460 100644
--- a/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/JmsDestinationBackedMessageChannelTests.java
+++ b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/JmsDestinationBackedMessageChannelTests.java
@@ -20,9 +20,14 @@ import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Before;
import org.junit.Test;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.context.support.StaticApplicationContext;
import org.springframework.integration.core.Message;
import org.springframework.integration.message.MessageHandler;
import org.springframework.integration.message.StringMessage;
@@ -77,6 +82,7 @@ public class JmsDestinationBackedMessageChannelTests {
JmsDestinationBackedMessageChannel channel =
new JmsDestinationBackedMessageChannel(this.connectionFactory, this.queue);
channel.afterPropertiesSet();
+ channel.start();
channel.subscribe(handler1);
channel.subscribe(handler2);
channel.send(new StringMessage("foo"));
@@ -88,6 +94,7 @@ public class JmsDestinationBackedMessageChannelTests {
assertEquals(1, receivedList2.size());
assertNotNull(receivedList2.get(0));
assertEquals("bar", receivedList2.get(0).getPayload());
+ channel.stop();
}
@Test
@@ -110,6 +117,7 @@ public class JmsDestinationBackedMessageChannelTests {
JmsDestinationBackedMessageChannel channel =
new JmsDestinationBackedMessageChannel(this.connectionFactory, this.topic);
channel.afterPropertiesSet();
+ channel.start();
channel.subscribe(handler1);
channel.subscribe(handler2);
channel.send(new StringMessage("foo"));
@@ -121,6 +129,7 @@ public class JmsDestinationBackedMessageChannelTests {
assertEquals(2, receivedList2.size());
assertEquals("foo", receivedList2.get(0).getPayload());
assertEquals("bar", receivedList2.get(1).getPayload());
+ channel.stop();
}
@Test
@@ -143,6 +152,7 @@ public class JmsDestinationBackedMessageChannelTests {
JmsDestinationBackedMessageChannel channel =
new JmsDestinationBackedMessageChannel(this.connectionFactory, "dynamicQueue", false);
channel.afterPropertiesSet();
+ channel.start();
channel.subscribe(handler1);
channel.subscribe(handler2);
channel.send(new StringMessage("foo"));
@@ -154,6 +164,7 @@ public class JmsDestinationBackedMessageChannelTests {
assertEquals(1, receivedList2.size());
assertNotNull(receivedList2.get(0));
assertEquals("bar", receivedList2.get(0).getPayload());
+ channel.stop();
}
@Test
@@ -176,6 +187,7 @@ public class JmsDestinationBackedMessageChannelTests {
JmsDestinationBackedMessageChannel channel =
new JmsDestinationBackedMessageChannel(this.connectionFactory, "dynamicTopic", true);
channel.afterPropertiesSet();
+ channel.start();
channel.subscribe(handler1);
channel.subscribe(handler2);
channel.send(new StringMessage("foo"));
@@ -187,6 +199,23 @@ public class JmsDestinationBackedMessageChannelTests {
assertEquals(2, receivedList2.size());
assertEquals("foo", receivedList2.get(0).getPayload());
assertEquals("bar", receivedList2.get(1).getPayload());
+ channel.stop();
+ }
+
+ @Test
+ public void contextManagesLifecycle() {
+ BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(JmsDestinationBackedMessageChannel.class);
+ builder.addConstructorArgValue(this.connectionFactory);
+ builder.addConstructorArgValue("dynamicQueue");
+ builder.addConstructorArgValue(false);
+ StaticApplicationContext context = new StaticApplicationContext();
+ context.registerBeanDefinition("channel", builder.getBeanDefinition());
+ JmsDestinationBackedMessageChannel channel = context.getBean("channel", JmsDestinationBackedMessageChannel.class);
+ assertFalse(channel.isRunning());
+ context.refresh();
+ assertTrue(channel.isRunning());
+ context.stop();
+ assertFalse(channel.isRunning());
}
}
diff --git a/org.springframework.integration.mail/.classpath b/org.springframework.integration.mail/.classpath
index 9c3752fd95..25eca77c61 100644
--- a/org.springframework.integration.mail/.classpath
+++ b/org.springframework.integration.mail/.classpath
@@ -9,13 +9,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java b/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java
index e1f1f15985..afd0889ca5 100755
--- a/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java
+++ b/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java
@@ -41,8 +41,6 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport {
private final IdleTask idleTask = new IdleTask();
- private volatile boolean autoStartup = true;
-
private volatile boolean shouldReconnectAutomatically = true;
private volatile TaskExecutor taskExecutor;
@@ -65,10 +63,6 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport {
this.shouldReconnectAutomatically = shouldReconnectAutomatically;
}
- public void setAutoStartup(boolean autoStartup) {
- this.autoStartup = autoStartup;
- }
-
public void setTaskExecutor(TaskExecutor taskExecutor) {
this.taskExecutor = taskExecutor;
}
@@ -79,16 +73,6 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport {
}
}
- @Override
- protected void onInit() {
- if (this.autoStartup) {
- this.setStartupMode(StartupMode.ON_CONTEXT_REFRESH);
- }
- else {
- this.setStartupMode(StartupMode.MANUAL);
- }
- }
-
/*
* Lifecycle implementation
*/
diff --git a/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/PollingMailSourceParserTests.java b/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/PollingMailSourceParserTests.java
index 6384baa1a9..7707976ca9 100644
--- a/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/PollingMailSourceParserTests.java
+++ b/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/PollingMailSourceParserTests.java
@@ -29,7 +29,6 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
-import org.springframework.integration.endpoint.AbstractEndpoint.StartupMode;
import org.springframework.integration.mail.ImapMailReceiver;
import org.springframework.integration.mail.MailReceivingMessageSource;
import org.springframework.integration.mail.Pop3MailReceiver;
@@ -53,7 +52,7 @@ public class PollingMailSourceParserTests {
Object adapter = context.getBean("imapAdapter");
assertEquals(SourcePollingChannelAdapter.class, adapter.getClass());
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
- assertEquals(StartupMode.MANUAL, adapterAccessor.getPropertyValue("startupMode"));
+ assertEquals(Boolean.FALSE, adapterAccessor.getPropertyValue("autoStartup"));
Object channel = context.getBean("channel");
assertEquals(channel, adapterAccessor.getPropertyValue("outputChannel"));
Object source = adapterAccessor.getPropertyValue("source");
@@ -72,7 +71,7 @@ public class PollingMailSourceParserTests {
Object adapter = context.getBean("pop3Adapter");
assertEquals(SourcePollingChannelAdapter.class, adapter.getClass());
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
- assertEquals(StartupMode.MANUAL, adapterAccessor.getPropertyValue("startupMode"));
+ assertEquals(Boolean.FALSE, adapterAccessor.getPropertyValue("autoStartup"));
Object channel = context.getBean("channel");
assertEquals(channel, adapterAccessor.getPropertyValue("outputChannel"));
Object source = adapterAccessor.getPropertyValue("source");
diff --git a/org.springframework.integration.osgi/.classpath b/org.springframework.integration.osgi/.classpath
index d53a3f79df..29a648b448 100644
--- a/org.springframework.integration.osgi/.classpath
+++ b/org.springframework.integration.osgi/.classpath
@@ -23,10 +23,10 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/org.springframework.integration.osgi/ivy.xml b/org.springframework.integration.osgi/ivy.xml
index ec7f19344b..8a871cd273 100644
--- a/org.springframework.integration.osgi/ivy.xml
+++ b/org.springframework.integration.osgi/ivy.xml
@@ -22,6 +22,7 @@
+
diff --git a/org.springframework.integration.rmi/.classpath b/org.springframework.integration.rmi/.classpath
index e81e468ad0..299a4680f4 100644
--- a/org.springframework.integration.rmi/.classpath
+++ b/org.springframework.integration.rmi/.classpath
@@ -8,13 +8,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/org.springframework.integration.security/.classpath b/org.springframework.integration.security/.classpath
index 257afce8aa..3b5acd3924 100644
--- a/org.springframework.integration.security/.classpath
+++ b/org.springframework.integration.security/.classpath
@@ -9,14 +9,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/org.springframework.integration.stream/.classpath b/org.springframework.integration.stream/.classpath
index 9d43f5c5b5..1523643146 100644
--- a/org.springframework.integration.stream/.classpath
+++ b/org.springframework.integration.stream/.classpath
@@ -7,12 +7,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/org.springframework.integration.test/.classpath b/org.springframework.integration.test/.classpath
index fa5058f08d..3f3c6705c3 100644
--- a/org.springframework.integration.test/.classpath
+++ b/org.springframework.integration.test/.classpath
@@ -9,15 +9,15 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/org.springframework.integration.udp/.classpath b/org.springframework.integration.udp/.classpath
index 19a7952e68..98e54451d2 100644
--- a/org.springframework.integration.udp/.classpath
+++ b/org.springframework.integration.udp/.classpath
@@ -7,12 +7,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/org.springframework.integration.ws/.classpath b/org.springframework.integration.ws/.classpath
index a0c05e6b65..dc46c4f5f6 100644
--- a/org.springframework.integration.ws/.classpath
+++ b/org.springframework.integration.ws/.classpath
@@ -9,15 +9,15 @@
-
-
-
-
-
+
+
+
+
+
-
+
diff --git a/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/SimpleWebServiceInboundGatewayTests.java b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/SimpleWebServiceInboundGatewayTests.java
index 0915fc87a9..abe89a6f8e 100644
--- a/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/SimpleWebServiceInboundGatewayTests.java
+++ b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/SimpleWebServiceInboundGatewayTests.java
@@ -37,8 +37,6 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnit44Runner;
import org.mockito.stubbing.Answer;
-import org.springframework.context.event.ContextRefreshedEvent;
-import org.springframework.context.support.StaticApplicationContext;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
@@ -92,7 +90,7 @@ public class SimpleWebServiceInboundGatewayTests {
when(requestChannel.send(isA(Message.class))).thenAnswer(
withReplyTo(replyChannel));
when(request.getPayloadSource()).thenReturn(payloadSource);
- gateway.onApplicationEvent(new ContextRefreshedEvent(new StaticApplicationContext()));
+ gateway.start();
gateway.invoke(context);
verify(requestChannel).send(messageWithPayload(payloadSource));
assertTrue(output.toString().endsWith(input));
diff --git a/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java
index c9f1ded565..9b94027626 100644
--- a/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java
+++ b/org.springframework.integration.ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java
@@ -27,7 +27,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.PollingConsumer;
-import org.springframework.integration.endpoint.AbstractEndpoint.StartupMode;
import org.springframework.integration.ws.MarshallingWebServiceOutboundGateway;
import org.springframework.integration.ws.SimpleWebServiceOutboundGateway;
import org.springframework.oxm.Marshaller;
@@ -222,7 +221,7 @@ public class WebServiceOutboundGatewayParserTests {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithOrderAndAutoStartupFalse");
- assertEquals(StartupMode.MANUAL, new DirectFieldAccessor(endpoint).getPropertyValue("startupMode"));
+ assertEquals(Boolean.FALSE, new DirectFieldAccessor(endpoint).getPropertyValue("autoStartup"));
}
@Test
diff --git a/org.springframework.integration.xml/.classpath b/org.springframework.integration.xml/.classpath
index 9418de8231..10ab1f539c 100644
--- a/org.springframework.integration.xml/.classpath
+++ b/org.springframework.integration.xml/.classpath
@@ -11,14 +11,14 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
diff --git a/org.springframework.integration/.classpath b/org.springframework.integration/.classpath
index 7fb9c0b1d6..fda722376c 100644
--- a/org.springframework.integration/.classpath
+++ b/org.springframework.integration/.classpath
@@ -11,15 +11,14 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java
index ae3a6bba2a..cd7259f4b4 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java
@@ -22,9 +22,7 @@ import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.Lifecycle;
-import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.SmartLifecycle;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.channel.SubscribableChannel;
import org.springframework.integration.context.IntegrationContextUtils;
@@ -32,7 +30,6 @@ import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.PollingConsumer;
-import org.springframework.integration.endpoint.AbstractEndpoint.StartupMode;
import org.springframework.integration.message.MessageHandler;
import org.springframework.integration.scheduling.PollerMetadata;
import org.springframework.util.Assert;
@@ -40,8 +37,8 @@ import org.springframework.util.Assert;
/**
* @author Mark Fisher
*/
-public class ConsumerEndpointFactoryBean implements FactoryBean, BeanFactoryAware, BeanNameAware,
- InitializingBean, Lifecycle, ApplicationListener {
+public class ConsumerEndpointFactoryBean
+ implements FactoryBean, BeanFactoryAware, BeanNameAware, InitializingBean, SmartLifecycle {
private volatile MessageHandler handler;
@@ -155,20 +152,26 @@ public class ConsumerEndpointFactoryBean implements FactoryBean, BeanFactoryAwar
}
this.endpoint.setBeanName(this.beanName);
this.endpoint.setBeanFactory(this.beanFactory);
- if (!this.autoStartup) {
- this.endpoint.setStartupMode(StartupMode.MANUAL);
- }
+ this.endpoint.setAutoStartup(this.autoStartup);
this.endpoint.afterPropertiesSet();
this.initialized = true;
}
}
/*
- * Lifecycle implementation
+ * SmartLifecycle implementation (delegates to the created endpoint)
*/
+ public boolean isAutoStartup() {
+ return (this.endpoint != null) ? this.endpoint.isAutoStartup() : true;
+ }
+
+ public int getPhase() {
+ return (this.endpoint != null) ? this.endpoint.getPhase() : 0;
+ }
+
public boolean isRunning() {
- return (this.endpoint != null ? this.endpoint.isRunning() : false);
+ return (this.endpoint != null) ? this.endpoint.isRunning() : false;
}
public void start() {
@@ -183,12 +186,10 @@ public class ConsumerEndpointFactoryBean implements FactoryBean, BeanFactoryAwar
}
}
- /*
- * ApplicationListener implementation
- */
-
- public void onApplicationEvent(ContextRefreshedEvent event) {
- this.endpoint.onApplicationEvent(event);
+ public void stop(Runnable callback) {
+ if (this.endpoint != null) {
+ this.endpoint.stop(callback);
+ }
}
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/SourcePollingChannelAdapterFactoryBean.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/SourcePollingChannelAdapterFactoryBean.java
index b7885c7d19..33d2020153 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/SourcePollingChannelAdapterFactoryBean.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/SourcePollingChannelAdapterFactoryBean.java
@@ -23,13 +23,10 @@ import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.Lifecycle;
-import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.SmartLifecycle;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
-import org.springframework.integration.endpoint.AbstractEndpoint.StartupMode;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.scheduling.PollerMetadata;
import org.springframework.util.Assert;
@@ -40,7 +37,7 @@ import org.springframework.util.Assert;
* @author Mark Fisher
*/
public class SourcePollingChannelAdapterFactoryBean implements FactoryBean, BeanFactoryAware, BeanNameAware,
- BeanClassLoaderAware, InitializingBean, Lifecycle, ApplicationListener {
+ BeanClassLoaderAware, InitializingBean, SmartLifecycle {
private volatile MessageSource> source;
@@ -97,12 +94,6 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean, Bean
this.initializeAdapter();
}
- public void onApplicationEvent(ContextRefreshedEvent event) {
- if (this.adapter != null) {
- this.adapter.onApplicationEvent(event);
- }
- }
-
public Object getObject() throws Exception {
if (this.adapter == null) {
this.initializeAdapter();
@@ -139,9 +130,7 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean, Bean
spca.setTransactionManager(this.pollerMetadata.getTransactionManager());
spca.setTransactionDefinition(this.pollerMetadata.getTransactionDefinition());
spca.setAdviceChain(this.pollerMetadata.getAdviceChain());
- if (!this.autoStartup) {
- spca.setStartupMode(StartupMode.MANUAL);
- }
+ spca.setAutoStartup(this.autoStartup);
spca.setBeanName(this.beanName);
spca.setBeanFactory(this.beanFactory);
spca.setBeanClassLoader(this.beanClassLoader);
@@ -152,14 +141,19 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean, Bean
}
/*
- * Lifecycle implementation (delegates to the created adapter).
+ * SmartLifecycle implementation (delegates to the created adapter)
*/
+ public boolean isAutoStartup() {
+ return (this.adapter != null) ? this.adapter.isAutoStartup() : true;
+ }
+
+ public int getPhase() {
+ return (this.adapter != null) ? this.adapter.getPhase() : 0;
+ }
+
public boolean isRunning() {
- if (this.adapter == null) {
- return false;
- }
- return this.adapter.isRunning();
+ return (this.adapter != null) ? this.adapter.isRunning() : false;
}
public void start() {
@@ -174,4 +168,10 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean, Bean
}
}
+ public void stop(Runnable callback) {
+ if (this.adapter != null) {
+ this.adapter.stop(callback);
+ }
+ }
+
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java
index 7a2f94071c..58651df129 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java
@@ -40,6 +40,8 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
+import org.springframework.context.Lifecycle;
+import org.springframework.context.SmartLifecycle;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.Router;
@@ -60,7 +62,7 @@ import org.springframework.util.StringUtils;
* @author Mark Fisher
* @author Marius Bogoevici
*/
-public class MessagingAnnotationPostProcessor implements BeanPostProcessor, BeanFactoryAware, InitializingBean, ApplicationListener {
+public class MessagingAnnotationPostProcessor implements BeanPostProcessor, BeanFactoryAware, InitializingBean, Lifecycle, ApplicationListener {
private final Log logger = LogFactory.getLog(this.getClass());
@@ -70,7 +72,11 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean
private final Map, MethodAnnotationPostProcessor>> postProcessors =
new HashMap, MethodAnnotationPostProcessor>>();
- private Set listeners = new HashSet();
+ private final Set listeners = new HashSet();
+
+ private final Set lifecycles = new HashSet();
+
+ private volatile boolean running = true;
public void setBeanFactory(BeanFactory beanFactory) {
@@ -124,6 +130,12 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean
throw new BeanInitializationException("failed to initialize annotated component", e);
}
}
+ if (result instanceof Lifecycle) {
+ lifecycles.add((Lifecycle) result);
+ if (result instanceof SmartLifecycle && ((SmartLifecycle) result).isAutoStartup()) {
+ ((SmartLifecycle) result).start();
+ }
+ }
if (result instanceof ApplicationListener) {
listeners.add((ApplicationListener) result);
}
@@ -185,4 +197,29 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean
}
}
+
+ // Lifecycle implementation
+
+ public boolean isRunning() {
+ return this.running;
+ }
+
+ public void start() {
+ for (Lifecycle lifecycle : this.lifecycles) {
+ if (!lifecycle.isRunning()) {
+ lifecycle.start();
+ }
+ }
+ this.running = true;
+ }
+
+ public void stop() {
+ for (Lifecycle lifecycle : this.lifecycles) {
+ if (lifecycle.isRunning()) {
+ lifecycle.stop();
+ }
+ }
+ this.running = false;
+ }
+
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java
index 637432cffe..4c044e278b 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java
@@ -20,10 +20,7 @@ import java.util.concurrent.locks.ReentrantLock;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.Lifecycle;
-import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.SmartLifecycle;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.scheduling.TaskScheduler;
@@ -39,25 +36,23 @@ import org.springframework.scheduling.TaskScheduler;
*
* @author Mark Fisher
*/
-public abstract class AbstractEndpoint extends IntegrationObjectSupport
- implements ApplicationListener, Lifecycle, InitializingBean {
+public abstract class AbstractEndpoint extends IntegrationObjectSupport implements SmartLifecycle, InitializingBean {
- public static enum StartupMode {
- MANUAL,
- ON_INITIALIZATION,
- ON_CONTEXT_REFRESH;
- }
+ private volatile boolean autoStartup = true;
-
- private volatile StartupMode startupMode = StartupMode.MANUAL;
+ private volatile int phase = 0;
private volatile boolean running;
private final ReentrantLock lifecycleLock = new ReentrantLock();
- public void setStartupMode(StartupMode startupMode) {
- this.startupMode = (startupMode != null ? startupMode : StartupMode.MANUAL);
+ public void setAutoStartup(boolean autoStartup) {
+ this.autoStartup = autoStartup;
+ }
+
+ public void setPhase(int phase) {
+ this.phase = phase;
}
public void setTaskScheduler(TaskScheduler taskScheduler) {
@@ -67,23 +62,21 @@ public abstract class AbstractEndpoint extends IntegrationObjectSupport
public final void afterPropertiesSet() {
try {
this.onInit();
- if (this.startupMode == StartupMode.ON_INITIALIZATION) {
- this.start();
- }
}
catch (Exception e) {
throw new BeanInitializationException("failed to initialize", e);
}
}
- public void onApplicationEvent(ApplicationEvent event) {
- if (event instanceof ContextRefreshedEvent
- && this.startupMode == StartupMode.ON_CONTEXT_REFRESH) {
- this.start();
- }
+ // SmartLifecycle implementation
+
+ public final boolean isAutoStartup() {
+ return this.autoStartup;
}
- // Lifecycle implementation
+ public final int getPhase() {
+ return this.phase;
+ }
public final boolean isRunning() {
this.lifecycleLock.lock();
@@ -127,6 +120,17 @@ public abstract class AbstractEndpoint extends IntegrationObjectSupport
}
}
+ public final void stop(Runnable callback) {
+ this.lifecycleLock.lock();
+ try {
+ this.stop();
+ callback.run();
+ }
+ finally {
+ this.lifecycleLock.unlock();
+ }
+ }
+
protected void onInit() throws Exception {
}
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 4879cf520d..753993ddd0 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
@@ -75,7 +75,7 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
public AbstractPollingEndpoint() {
- this.setStartupMode(StartupMode.ON_CONTEXT_REFRESH);
+ this.setPhase(Integer.MAX_VALUE);
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java
index 36c628c22f..ddaa794bfc 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java
@@ -36,9 +36,9 @@ public class EventDrivenConsumer extends AbstractEndpoint {
public EventDrivenConsumer(SubscribableChannel inputChannel, MessageHandler handler) {
Assert.notNull(inputChannel, "inputChannel must not be null");
Assert.notNull(handler, "handler must not be null");
- this.setStartupMode(StartupMode.ON_INITIALIZATION);
this.inputChannel = inputChannel;
this.handler = handler;
+ this.setPhase(Integer.MIN_VALUE);
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/PollingConsumer.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/PollingConsumer.java
index 919c07f134..45da05398c 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/PollingConsumer.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/PollingConsumer.java
@@ -39,7 +39,6 @@ public class PollingConsumer extends AbstractPollingEndpoint {
public PollingConsumer(PollableChannel inputChannel, MessageHandler handler) {
Assert.notNull(inputChannel, "inputChannel must not be null");
Assert.notNull(handler, "handler must not be null");
- this.setStartupMode(StartupMode.ON_CONTEXT_REFRESH);
this.inputChannel = inputChannel;
this.handler = handler;
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/gateway/AbstractMessagingGateway.java b/org.springframework.integration/src/main/java/org/springframework/integration/gateway/AbstractMessagingGateway.java
index d6ed4b1628..fd4eccb426 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/gateway/AbstractMessagingGateway.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/gateway/AbstractMessagingGateway.java
@@ -51,8 +51,6 @@ public abstract class AbstractMessagingGateway extends AbstractEndpoint implemen
private volatile boolean shouldThrowErrors = true;
- private volatile boolean autoStartup = true;
-
private volatile boolean initialized;
private volatile AbstractEndpoint replyMessageCorrelator;
@@ -109,23 +107,8 @@ public abstract class AbstractMessagingGateway extends AbstractEndpoint implemen
this.shouldThrowErrors = shouldThrowErrors;
}
- public void setAutoStartup(boolean autoStartup) {
- this.autoStartup = autoStartup;
- }
-
@Override
protected void onInit() throws Exception {
- if (this.autoStartup) {
- if (this.requestChannel instanceof PollableChannel) {
- this.setStartupMode(StartupMode.ON_CONTEXT_REFRESH);
- }
- else {
- this.setStartupMode(StartupMode.ON_INITIALIZATION);
- }
- }
- else {
- this.setStartupMode(StartupMode.MANUAL);
- }
this.initialized = true;
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java
index 05e07d5abf..ee86e3bea3 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java
@@ -30,10 +30,11 @@ import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.core.MethodParameter;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.core.annotation.AnnotationUtils;
+import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.Converter;
-import org.springframework.core.convert.support.DefaultConversionService;
-import org.springframework.core.convert.support.GenericConversionService;
+import org.springframework.core.convert.converter.ConverterRegistry;
+import org.springframework.core.convert.support.ConversionServiceFactory;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
@@ -108,17 +109,18 @@ import org.springframework.util.StringUtils;
*/
public class ArgumentArrayMessageMapper implements InboundMessageMapper