INT-1899 polishing

This commit is contained in:
Mark Fisher
2011-05-16 16:56:25 -04:00
parent c1e6978248
commit 5bf5d1f145
2 changed files with 13 additions and 10 deletions

View File

@@ -100,14 +100,11 @@ public abstract class AbstractConsumerEndpointParser extends AbstractBeanDefinit
else {
channelExists = parserContext.getRegistry().containsBeanDefinition(inputChannelName);
}
if (!channelExists) {
// create a default DirectChannel instance
if (!IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME.equals(inputChannelName)){
BeanDefinitionBuilder channelDef = BeanDefinitionBuilder.genericBeanDefinition(
IntegrationNamespaceUtils.BASE_PACKAGE + ".channel.DirectChannel");
BeanDefinitionHolder holder = new BeanDefinitionHolder(channelDef.getBeanDefinition(), inputChannelName);
BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
}
if (!channelExists && this.shouldAutoCreateChannel(inputChannelName)) {
BeanDefinitionBuilder channelDef = BeanDefinitionBuilder.genericBeanDefinition(
IntegrationNamespaceUtils.BASE_PACKAGE + ".channel.DirectChannel");
BeanDefinitionHolder holder = new BeanDefinitionHolder(channelDef.getBeanDefinition(), inputChannelName);
BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
}
builder.addPropertyValue("inputChannelName", inputChannelName);
List<Element> pollerElementList = DomUtils.getChildElementsByTagName(element, "poller");
@@ -126,4 +123,9 @@ public abstract class AbstractConsumerEndpointParser extends AbstractBeanDefinit
return null;
}
private boolean shouldAutoCreateChannel(String channelName) {
return !IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME.equals(channelName)
&& !IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME.equals(channelName);
}
}

View File

@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.config.xml;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,7 +41,7 @@ public class ErrorChannelAutoCreationTests {
// see INT-1899
@Test
public void testErrorChannelIsPubSub(){
assertTrue(errorChannel instanceof PublishSubscribeChannel);
assertEquals(PublishSubscribeChannel.class, errorChannel.getClass());
}
}