Refactored to use common ChannelAdapterParser for inbound and outbound

This commit is contained in:
Mark Fisher
2007-12-15 16:01:57 +00:00
parent 96d13da7f3
commit 2cd6518a5a
5 changed files with 16 additions and 65 deletions

View File

@@ -27,6 +27,9 @@ import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.endpoint.annotation.MessageEndpointAnnotationPostProcessor;
/**
* Parser for the <em>annotation-driven</em> element of the integration
* namespace. Registers the annotation-driven post-processors.
*
* @author Mark Fisher
*/
public class AnnotationDrivenParser implements BeanDefinitionParser {

View File

@@ -29,11 +29,11 @@ import org.springframework.integration.endpoint.OutboundMethodInvokingChannelAda
import org.springframework.util.StringUtils;
/**
* Base parser for inbound and outbound channel adapters.
* Parser for inbound and outbound channel adapters.
*
* @author Mark Fisher
*/
public abstract class AbstractChannelAdapterParser implements BeanDefinitionParser {
public class ChannelAdapterParser implements BeanDefinitionParser {
private static final String ID_ATTRIBUTE = "id";
@@ -42,9 +42,17 @@ public abstract class AbstractChannelAdapterParser implements BeanDefinitionPars
private static final String METHOD_ATTRIBUTE = "method";
private final boolean isInbound;
public ChannelAdapterParser(boolean isInbound) {
this.isInbound = isInbound;
}
public BeanDefinition parse(Element element, ParserContext parserContext) {
RootBeanDefinition adapterDef = null;
if (this.isInbound()) {
if (this.isInbound) {
adapterDef = new RootBeanDefinition(InboundMethodInvokingChannelAdapter.class);
}
else {
@@ -65,6 +73,4 @@ public abstract class AbstractChannelAdapterParser implements BeanDefinitionPars
return adapterDef;
}
protected abstract boolean isInbound();
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2002-2007 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;
/**
* @author Mark Fisher
*/
public class InboundChannelAdapterParser extends AbstractChannelAdapterParser {
@Override
protected boolean isInbound() {
return true;
}
}

View File

@@ -29,8 +29,8 @@ public class IntegrationNamespaceHandler extends NamespaceHandlerSupport {
registerBeanDefinitionParser("message-bus", new MessageBusParser());
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenParser());
registerBeanDefinitionParser("channel", new ChannelParser());
registerBeanDefinitionParser("inbound-channel-adapter", new InboundChannelAdapterParser());
registerBeanDefinitionParser("outbound-channel-adapter", new OutboundChannelAdapterParser());
registerBeanDefinitionParser("inbound-channel-adapter", new ChannelAdapterParser(true));
registerBeanDefinitionParser("outbound-channel-adapter", new ChannelAdapterParser(false));
registerBeanDefinitionParser("endpoint", new EndpointParser());
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2002-2007 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;
/**
* @author Mark Fisher
*/
public class OutboundChannelAdapterParser extends AbstractChannelAdapterParser {
@Override
protected boolean isInbound() {
return false;
}
}