INT-2404 Fix Auto-Created Channel; Event, TCP, UDP
The AbstractChannelAdapterParser creates an implicit DirectChannel if the adapter has no 'channel' attribute. The Event, TCP, and UDP channel adapter parsers did not bind this channel to the adapter and AC initialization failed with 'outputChannel is required'. Further, the event schema marked the channel as being 'required', precluding this feature. INT-2407 Remove Channel use="required" Parsers automatically generate the channel when none is provided. - JMX - JDBC - SFTP - Redis - Feed - XMPP - Mail - FTP - HTTP
This commit is contained in:
committed by
Mark Fisher
parent
e7b514a1e4
commit
292aa90599
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 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,19 +16,20 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.integration.jmx.NotificationListeningMessageProducer;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
public class NotificationListeningChannelAdapterParser extends AbstractSimpleBeanDefinitionParser {
|
||||
public class NotificationListeningChannelAdapterParser extends AbstractChannelAdapterParser {
|
||||
|
||||
@Override
|
||||
protected boolean shouldGenerateIdAsFallback() {
|
||||
@@ -36,23 +37,16 @@ public class NotificationListeningChannelAdapterParser extends AbstractSimpleBea
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
return "org.springframework.integration.jmx.NotificationListeningMessageProducer";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
Object source = parserContext.extractSource(element);
|
||||
String channel = element.getAttribute("channel");
|
||||
if (!StringUtils.hasText(channel)) {
|
||||
parserContext.getReaderContext().error("The 'channel' attribute is required.", source);
|
||||
}
|
||||
builder.addPropertyReference("outputChannel", channel);
|
||||
protected AbstractBeanDefinition doParse(Element element,
|
||||
ParserContext parserContext, String channelName) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(NotificationListeningMessageProducer.class);
|
||||
builder.addPropertyReference("outputChannel", channelName);
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "server");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "notification-filter", "filter");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "handback");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "object-name");
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user