diff --git a/org.springframework.integration.httpinvoker/src/main/java/org/springframework/integration/httpinvoker/config/HttpInvokerInboundGatewayParser.java b/org.springframework.integration.httpinvoker/src/main/java/org/springframework/integration/httpinvoker/config/HttpInvokerInboundGatewayParser.java index 4f6c1a565a..a9442c8ec1 100644 --- a/org.springframework.integration.httpinvoker/src/main/java/org/springframework/integration/httpinvoker/config/HttpInvokerInboundGatewayParser.java +++ b/org.springframework.integration.httpinvoker/src/main/java/org/springframework/integration/httpinvoker/config/HttpInvokerInboundGatewayParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 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. @@ -18,7 +18,7 @@ package org.springframework.integration.httpinvoker.config; import org.w3c.dom.Element; -import org.springframework.integration.adapter.config.AbstractRemotingGatewayParser; +import org.springframework.integration.config.xml.AbstractInboundGatewayParser; /** * Parser for the <httpinvoker-gateway/> element. @@ -28,7 +28,7 @@ import org.springframework.integration.adapter.config.AbstractRemotingGatewayPar * @deprecated as of 2.0.x. We recommend using the REST-based HTTP adapters instead. */ @Deprecated -public class HttpInvokerInboundGatewayParser extends AbstractRemotingGatewayParser { +public class HttpInvokerInboundGatewayParser extends AbstractInboundGatewayParser { @Override protected String getBeanClassName(Element element) { diff --git a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/config/IpInboundGatewayParser.java b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/config/IpInboundGatewayParser.java index 56771156cc..9543a5166d 100644 --- a/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/config/IpInboundGatewayParser.java +++ b/org.springframework.integration.ip/src/main/java/org/springframework/integration/ip/config/IpInboundGatewayParser.java @@ -13,43 +13,34 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.ip.config; +import org.w3c.dom.Element; + + import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.core.Conventions; -import org.springframework.integration.adapter.config.AbstractRemotingGatewayParser; +import org.springframework.integration.config.xml.AbstractInboundGatewayParser; import org.springframework.integration.ip.tcp.SimpleTcpNetInboundGateway; -import org.w3c.dom.Element; - -import sun.print.IPPPrintService; /** * @author Gary Russell - * + * @since 2.0 */ -public class IpInboundGatewayParser extends AbstractRemotingGatewayParser { +public class IpInboundGatewayParser extends AbstractInboundGatewayParser { - - /* (non-Javadoc) - * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#getBeanClass(org.w3c.dom.Element) - */ @Override - protected Class getBeanClass(Element element) { + protected Class getBeanClass(Element element) { return SimpleTcpNetInboundGateway.class; } - /* (non-Javadoc) - * @see org.springframework.integration.adapter.config.AbstractRemotingGatewayParser#isEligibleAttribute(java.lang.String) - */ @Override protected boolean isEligibleAttribute(String attributeName) { return !attributeName.equals(IpAdapterParserUtils.MESSAGE_FORMAT) && super.isEligibleAttribute(attributeName); } - /* (non-Javadoc) - * @see org.springframework.integration.adapter.config.AbstractRemotingGatewayParser#doPostProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.w3c.dom.Element) - */ @Override protected void doPostProcess(BeanDefinitionBuilder builder, Element element) { builder.addPropertyValue( @@ -57,5 +48,4 @@ public class IpInboundGatewayParser extends AbstractRemotingGatewayParser { IpAdapterParserUtils.getMessageFormat(element)); } - } diff --git a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiInboundGatewayParser.java b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiInboundGatewayParser.java index acce4a382c..9ebd0077db 100644 --- a/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiInboundGatewayParser.java +++ b/org.springframework.integration.rmi/src/main/java/org/springframework/integration/rmi/config/RmiInboundGatewayParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 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. @@ -19,7 +19,7 @@ package org.springframework.integration.rmi.config; import org.w3c.dom.Element; import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.integration.adapter.config.AbstractRemotingGatewayParser; +import org.springframework.integration.config.xml.AbstractInboundGatewayParser; import org.springframework.util.StringUtils; /** @@ -27,7 +27,7 @@ import org.springframework.util.StringUtils; * * @author Mark Fisher */ -public class RmiInboundGatewayParser extends AbstractRemotingGatewayParser { +public class RmiInboundGatewayParser extends AbstractInboundGatewayParser { private static final String REMOTE_INVOCATION_EXECUTOR_ATTRIBUTE = "remote-invocation-executor"; diff --git a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParser.java b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParser.java index aecef2873f..3bad423846 100644 --- a/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParser.java +++ b/org.springframework.integration.ws/src/main/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 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. @@ -15,27 +15,29 @@ */ package org.springframework.integration.ws.config; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.integration.adapter.config.AbstractRemotingGatewayParser; -import org.springframework.util.StringUtils; import org.w3c.dom.Element; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.integration.config.xml.AbstractInboundGatewayParser; +import org.springframework.util.StringUtils; + /** - * * @author Iwein Fuld - * */ -public class WebServiceInboundGatewayParser extends - AbstractRemotingGatewayParser { +public class WebServiceInboundGatewayParser extends AbstractInboundGatewayParser { @Override protected String getBeanClassName(Element element) { - String simpleClassName = (StringUtils.hasText(element - .getAttribute("marshaller"))) ? "MarshallingWebServiceInboundGateway" - : "SimpleWebServiceInboundGateway"; + String simpleClassName = (StringUtils.hasText(element.getAttribute("marshaller"))) ? + "MarshallingWebServiceInboundGateway" : "SimpleWebServiceInboundGateway"; return "org.springframework.integration.ws." + simpleClassName; } + @Override + protected boolean isEligibleAttribute(String attributeName) { + return !(attributeName.endsWith("marshaller")) && super.isEligibleAttribute(attributeName); + } + @Override protected void doPostProcess(BeanDefinitionBuilder builder, Element element) { String marshallerRef = element.getAttribute("marshaller"); @@ -47,8 +49,5 @@ public class WebServiceInboundGatewayParser extends } } } - @Override - protected boolean isEligibleAttribute(String attributeName) { - return !(attributeName.endsWith("marshaller")) && super.isEligibleAttribute(attributeName); - } + } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/AbstractInboundGatewayParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/AbstractInboundGatewayParser.java new file mode 100644 index 0000000000..d4533086fe --- /dev/null +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/AbstractInboundGatewayParser.java @@ -0,0 +1,77 @@ +/* + * Copyright 2002-2010 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.xml; + +import org.w3c.dom.Element; + +import org.springframework.beans.factory.BeanDefinitionStoreException; +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.util.Assert; +import org.springframework.util.StringUtils; + +/** + * Base class for inbound gateway parsers. + * + * @author Mark Fisher + */ +public abstract class AbstractInboundGatewayParser extends AbstractSimpleBeanDefinitionParser { + + @Override + protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) + throws BeanDefinitionStoreException { + String id = super.resolveId(element, definition, parserContext); + if (!StringUtils.hasText(id)) { + id = element.getAttribute("name"); + } + if (!StringUtils.hasText(id)) { + id = parserContext.getReaderContext().generateBeanName(definition); + } + return id; + } + + @Override + protected boolean isEligibleAttribute(String attributeName) { + return !attributeName.equals("name") && !attributeName.equals("request-channel") + && !attributeName.equals("reply-channel") && super.isEligibleAttribute(attributeName); + } + + @Override + protected final void postProcess(BeanDefinitionBuilder builder, Element element) { + String requestChannelRef = element.getAttribute("request-channel"); + Assert.hasText(requestChannelRef, "a 'request-channel' reference is required"); + builder.addPropertyReference("requestChannel", requestChannelRef); + String replyChannel = element.getAttribute("reply-channel"); + if (StringUtils.hasText(replyChannel)) { + builder.addPropertyReference("replyChannel", replyChannel); + } + String autoStartup = element.getAttribute("auto-startup"); + if (StringUtils.hasText(autoStartup)) { + builder.addPropertyValue("autoStartup", autoStartup); + } + this.doPostProcess(builder, element); + } + + /** + * Subclasses may add to the bean definition by overriding this method. + */ + protected void doPostProcess(BeanDefinitionBuilder builder, Element element) { + } + +}