Refactored to use common ChannelAdapterParser for inbound and outbound
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user