Added the "task-executor" attribute for the <message-bus/> element (INT-344).

This commit is contained in:
Mark Fisher
2008-08-18 22:07:22 +00:00
parent b6ef9c8e1a
commit e472e64309
5 changed files with 91 additions and 3 deletions

View File

@@ -44,6 +44,7 @@ import org.springframework.integration.channel.config.ChannelParserTests;
import org.springframework.integration.endpoint.DefaultEndpoint;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.handler.TestHandlers;
import org.springframework.integration.scheduling.TaskScheduler;
import org.springframework.integration.scheduling.spi.ProviderTaskScheduler;
/**
@@ -186,4 +187,15 @@ public class MessageBusParserTests {
MessageBusInterceptorTests.executeInterceptorsTest(messageBus, startInterceptor, stopInterceptor);
}
@Test
public void testMessageBusWithTaskScheduler() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"messageBusWithTaskScheduler.xml", this.getClass());
MessageBus messageBus = (MessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
StubTaskScheduler schedulerBean = (StubTaskScheduler) context.getBean("testScheduler");
TaskScheduler busScheduler = (TaskScheduler) new DirectFieldAccessor(messageBus).getPropertyValue("taskScheduler");
assertNotNull(busScheduler);
assertEquals(schedulerBean, busScheduler);
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.config;
import java.util.concurrent.ScheduledFuture;
import org.springframework.integration.scheduling.SchedulableTask;
import org.springframework.integration.scheduling.TaskScheduler;
import org.springframework.integration.util.ErrorHandler;
/**
* @author Mark Fisher
*/
public class StubTaskScheduler implements TaskScheduler {
public boolean cancel(Runnable task, boolean mayInterruptIfRunning) {
return false;
}
public ScheduledFuture<?> schedule(SchedulableTask task) {
return null;
}
public void setErrorHandler(ErrorHandler errorHandler) {
}
public boolean prefersShortLivedTasks() {
return false;
}
public void execute(Runnable task) {
}
public boolean isRunning() {
return false;
}
public void start() {
}
public void stop() {
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd">
<message-bus task-scheduler="testScheduler"/>
<beans:bean id="testScheduler" class="org.springframework.integration.config.StubTaskScheduler"/>
</beans:beans>