Removed the MessageBus interface. The ApplicationContextMessageBus now implements Lifecycle directly. The MessageEndpoint interface had no additional methods after the removal of registerEndpoint().
This commit is contained in:
@@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.integration.channel.BeanFactoryChannelResolver;
|
||||
@@ -118,7 +119,7 @@ public class ApplicationContextMessageBusTests {
|
||||
PollableChannel sourceChannel = (PollableChannel) context.getBean("sourceChannel");
|
||||
sourceChannel.send(new GenericMessage<String>("test"));
|
||||
PollableChannel targetChannel = (PollableChannel) context.getBean("targetChannel");
|
||||
MessageBus bus = (MessageBus) context.getBean("bus");
|
||||
Lifecycle bus = (Lifecycle) context.getBean("bus");
|
||||
bus.start();
|
||||
Message<?> result = targetChannel.receive(1000);
|
||||
assertEquals("test", result.getPayload());
|
||||
|
||||
@@ -74,25 +74,25 @@ public class MessageBusEventTests {
|
||||
|
||||
public static class TestMessageBusListener implements ApplicationListener {
|
||||
|
||||
private volatile MessageBus startedBus;
|
||||
private volatile ApplicationContextMessageBus startedBus;
|
||||
|
||||
private volatile MessageBus stoppedBus;
|
||||
private volatile ApplicationContextMessageBus stoppedBus;
|
||||
|
||||
|
||||
public MessageBus getStartedBus() {
|
||||
public ApplicationContextMessageBus getStartedBus() {
|
||||
return this.startedBus;
|
||||
}
|
||||
|
||||
public MessageBus getStoppedBus() {
|
||||
public ApplicationContextMessageBus getStoppedBus() {
|
||||
return this.stoppedBus;
|
||||
}
|
||||
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (event instanceof MessageBusStartedEvent) {
|
||||
this.startedBus = (MessageBus) event.getSource();
|
||||
this.startedBus = (ApplicationContextMessageBus) event.getSource();
|
||||
}
|
||||
if (event instanceof MessageBusStoppedEvent) {
|
||||
this.stoppedBus = (MessageBus) event.getSource();
|
||||
this.stoppedBus = (ApplicationContextMessageBus) event.getSource();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
|
||||
|
||||
<bean id="bus1" class="org.springframework.integration.bus.MessageBus"/>
|
||||
<bean id="bus1" class="org.springframework.integration.bus.ApplicationContextMessageBus"/>
|
||||
|
||||
<bean id="bus2" class="org.springframework.integration.bus.MessageBus"/>
|
||||
<bean id="bus2" class="org.springframework.integration.bus.ApplicationContextMessageBus"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -27,12 +27,12 @@ import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.context.event.SimpleApplicationEventMulticaster;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.task.SyncTaskExecutor;
|
||||
import org.springframework.integration.bus.ApplicationContextMessageBus;
|
||||
import org.springframework.integration.bus.MessageBus;
|
||||
import org.springframework.integration.bus.MessageBusEventTests.TestMessageBusListener;
|
||||
import org.springframework.integration.config.xml.MessageBusParser;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -94,7 +94,7 @@ public class MessageBusParserTests {
|
||||
public void testAutoStartup() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"messageBusWithAutoStartup.xml", this.getClass());
|
||||
MessageBus bus = (MessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
|
||||
Lifecycle bus = (Lifecycle) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
|
||||
assertTrue(bus.isRunning());
|
||||
bus.stop();
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class MessageBusParserTests {
|
||||
public void testMessageBusEventListenerReceivesStartedEvent() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"messageBusWithListener.xml", this.getClass());
|
||||
MessageBus messageBus = (MessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
|
||||
Lifecycle messageBus = (Lifecycle) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
|
||||
TestMessageBusListener listener = (TestMessageBusListener) context.getBean("listener");
|
||||
assertNull(listener.getStartedBus());
|
||||
assertNull(listener.getStoppedBus());
|
||||
@@ -152,7 +152,7 @@ public class MessageBusParserTests {
|
||||
public void testMessageBusEventListenerReceivesStoppedEvent() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"messageBusWithListener.xml", this.getClass());
|
||||
MessageBus messageBus = (MessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
|
||||
Lifecycle messageBus = (Lifecycle) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
|
||||
TestMessageBusListener listener = (TestMessageBusListener) context.getBean("listener");
|
||||
assertNull(listener.getStoppedBus());
|
||||
messageBus.start();
|
||||
@@ -165,7 +165,7 @@ public class MessageBusParserTests {
|
||||
public void testMessageBusWithTaskScheduler() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"messageBusWithTaskScheduler.xml", this.getClass());
|
||||
MessageBus messageBus = (MessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
|
||||
Object messageBus = context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
|
||||
StubTaskScheduler schedulerBean = (StubTaskScheduler) context.getBean("testScheduler");
|
||||
TaskScheduler busScheduler = (TaskScheduler) new DirectFieldAccessor(messageBus).getPropertyValue("taskScheduler");
|
||||
assertNotNull(busScheduler);
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.bus.MessageBus;
|
||||
import org.springframework.integration.bus.ApplicationContextMessageBus;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -55,7 +55,7 @@ public class AnnotatedEndpointActivationTests {
|
||||
private PollableChannel output;
|
||||
|
||||
@Autowired
|
||||
private MessageBus messageBus;
|
||||
private ApplicationContextMessageBus messageBus;
|
||||
|
||||
// This has to be static because the MessageBus registers the handler
|
||||
// more than once (every time a test instance is created), but only one of
|
||||
|
||||
Reference in New Issue
Block a user