Renamed 'invalidMessageChannel' to 'errorChannel'

This commit is contained in:
Mark Fisher
2008-01-16 16:38:14 +00:00
parent 22386aabb7
commit 2ffae06824
8 changed files with 26 additions and 26 deletions

View File

@@ -146,8 +146,8 @@ public class MessageBus implements ChannelRegistry, ApplicationContextAware, Lif
}
public void initialize() {
if (this.getInvalidMessageChannel() == null) {
this.setInvalidMessageChannel(new SimpleChannel(Integer.MAX_VALUE));
if (this.getErrorChannel() == null) {
this.setErrorChannel(new SimpleChannel(Integer.MAX_VALUE));
}
if (this.taskScheduler == null) {
this.setMessagingTaskScheduler(createDefaultScheduler());
@@ -162,17 +162,17 @@ public class MessageBus implements ChannelRegistry, ApplicationContextAware, Lif
SimpleMessagingTaskScheduler scheduler = new SimpleMessagingTaskScheduler();
scheduler.setCorePoolSize(this.dispatcherPoolSize);
scheduler.setThreadFactory(threadFactory);
scheduler.setErrorHandler(new MessagePublishingErrorHandler(this.getInvalidMessageChannel()));
scheduler.setErrorHandler(new MessagePublishingErrorHandler(this.getErrorChannel()));
scheduler.afterPropertiesSet();
return scheduler;
}
public MessageChannel getInvalidMessageChannel() {
return this.channelRegistry.getInvalidMessageChannel();
public MessageChannel getErrorChannel() {
return this.channelRegistry.getErrorChannel();
}
public void setInvalidMessageChannel(MessageChannel invalidMessageChannel) {
this.channelRegistry.setInvalidMessageChannel(invalidMessageChannel);
public void setErrorChannel(MessageChannel errorChannel) {
this.channelRegistry.setErrorChannel(errorChannel);
}
public MessageChannel lookupChannel(String channelName) {

View File

@@ -27,8 +27,8 @@ public interface ChannelRegistry {
MessageChannel lookupChannel(String channelName);
void setInvalidMessageChannel(MessageChannel invalidMessageChannel);
void setErrorChannel(MessageChannel errorChannel);
MessageChannel getInvalidMessageChannel();
MessageChannel getErrorChannel();
}

View File

@@ -30,15 +30,15 @@ public class DefaultChannelRegistry implements ChannelRegistry {
private Map<String, MessageChannel> channels = new ConcurrentHashMap<String, MessageChannel>();
private MessageChannel invalidMessageChannel;
private MessageChannel errorChannel;
public void setInvalidMessageChannel(MessageChannel invalidMessageChannel) {
this.invalidMessageChannel = invalidMessageChannel;
public void setErrorChannel(MessageChannel errorChannel) {
this.errorChannel = errorChannel;
}
public MessageChannel getInvalidMessageChannel() {
return this.invalidMessageChannel;
public MessageChannel getErrorChannel() {
return this.errorChannel;
}
public MessageChannel lookupChannel(String channelName) {

View File

@@ -36,7 +36,7 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser {
public static final String MESSAGE_BUS_BEAN_NAME = "org.springframework.integration.bus.internalMessageBus";
private static final String INVALID_MESSAGE_CHANNEL_ATTRIBUTE = "invalid-message-channel";
private static final String ERROR_CHANNEL_ATTRIBUTE = "error-channel";
@Override
@@ -52,15 +52,15 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected boolean isEligibleAttribute(String attributeName) {
return !INVALID_MESSAGE_CHANNEL_ATTRIBUTE.equals(attributeName) && super.isEligibleAttribute(attributeName);
return !ERROR_CHANNEL_ATTRIBUTE.equals(attributeName) && super.isEligibleAttribute(attributeName);
}
@Override
protected void postProcess(BeanDefinitionBuilder beanDefinition, Element element) {
String invalidMessageChannelRef = element.getAttribute(INVALID_MESSAGE_CHANNEL_ATTRIBUTE);
if (StringUtils.hasText(invalidMessageChannelRef)) {
String errorChannelRef = element.getAttribute(ERROR_CHANNEL_ATTRIBUTE);
if (StringUtils.hasText(errorChannelRef)) {
beanDefinition.addPropertyReference(Conventions.attributeNameToPropertyName(
INVALID_MESSAGE_CHANNEL_ATTRIBUTE), invalidMessageChannelRef);
ERROR_CHANNEL_ATTRIBUTE), errorChannelRef);
}
}

View File

@@ -25,7 +25,7 @@
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="auto-create-channels" type="xsd:boolean"/>
<xsd:attribute name="invalid-message-channel" type="xsd:string"/>
<xsd:attribute name="error-channel" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

View File

@@ -159,7 +159,7 @@ public class MessageBusTests {
}
@Test
public void testInvalidMessageChannelWithFailedDispatch() throws InterruptedException {
public void testErrorChannelWithFailedDispatch() throws InterruptedException {
MessageBus bus = new MessageBus();
CountDownLatch latch = new CountDownLatch(1);
SourceAdapter sourceAdapter = new PollingSourceAdapter<Object>(new FailingSource(latch));
@@ -167,7 +167,7 @@ public class MessageBusTests {
bus.registerSourceAdapter("testAdapter", sourceAdapter);
bus.start();
latch.await(1000, TimeUnit.MILLISECONDS);
Message<?> message = bus.getInvalidMessageChannel().receive(100);
Message<?> message = bus.getErrorChannel().receive(100);
assertNotNull("message should not be null", message);
assertTrue(message instanceof ErrorMessage);
assertEquals("intentional test failure", ((ErrorMessage) message).getPayload().getMessage());

View File

@@ -39,7 +39,7 @@ public class MessageBusParserTests {
"messageBusWithErrorChannelReference.xml", this.getClass());
MessageBus bus = (MessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
bus.initialize();
assertEquals(context.getBean("errorMessages"), bus.getInvalidMessageChannel());
assertEquals(context.getBean("testErrorChannel"), bus.getErrorChannel());
}
@Test
@@ -48,7 +48,7 @@ public class MessageBusParserTests {
"messageBusWithDefaults.xml", this.getClass());
MessageBus bus = (MessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
bus.initialize();
assertNotNull("bus should have created a default error channel", bus.getInvalidMessageChannel());
assertNotNull("bus should have created a default error channel", bus.getErrorChannel());
}
@Test(expected=MessagingConfigurationException.class)

View File

@@ -7,8 +7,8 @@
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<channel id="errorMessages"/>
<channel id="testErrorChannel"/>
<message-bus invalid-message-channel="errorMessages"/>
<message-bus error-channel="testErrorChannel"/>
</beans:beans>