INT-842 moved AbstractRemotingGatewayParser to the core 'config.xml' package and renamed AbstractInboundGatewayParser

This commit is contained in:
Mark Fisher
2010-04-30 23:15:08 +00:00
parent e0cc920d56
commit 4f56f3650b
5 changed files with 105 additions and 39 deletions

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.w3c.dom.Element;
import org.springframework.integration.adapter.config.AbstractRemotingGatewayParser; import org.springframework.integration.config.xml.AbstractInboundGatewayParser;
/** /**
* Parser for the <httpinvoker-gateway/> element. * 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 as of 2.0.x. We recommend using the REST-based HTTP adapters instead.
*/ */
@Deprecated @Deprecated
public class HttpInvokerInboundGatewayParser extends AbstractRemotingGatewayParser { public class HttpInvokerInboundGatewayParser extends AbstractInboundGatewayParser {
@Override @Override
protected String getBeanClassName(Element element) { protected String getBeanClassName(Element element) {

View File

@@ -13,43 +13,34 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.integration.ip.config; package org.springframework.integration.ip.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.core.Conventions; 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.springframework.integration.ip.tcp.SimpleTcpNetInboundGateway;
import org.w3c.dom.Element;
import sun.print.IPPPrintService;
/** /**
* @author Gary Russell * @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 @Override
protected Class getBeanClass(Element element) { protected Class<?> getBeanClass(Element element) {
return SimpleTcpNetInboundGateway.class; return SimpleTcpNetInboundGateway.class;
} }
/* (non-Javadoc)
* @see org.springframework.integration.adapter.config.AbstractRemotingGatewayParser#isEligibleAttribute(java.lang.String)
*/
@Override @Override
protected boolean isEligibleAttribute(String attributeName) { protected boolean isEligibleAttribute(String attributeName) {
return !attributeName.equals(IpAdapterParserUtils.MESSAGE_FORMAT) return !attributeName.equals(IpAdapterParserUtils.MESSAGE_FORMAT)
&& super.isEligibleAttribute(attributeName); && super.isEligibleAttribute(attributeName);
} }
/* (non-Javadoc)
* @see org.springframework.integration.adapter.config.AbstractRemotingGatewayParser#doPostProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.w3c.dom.Element)
*/
@Override @Override
protected void doPostProcess(BeanDefinitionBuilder builder, Element element) { protected void doPostProcess(BeanDefinitionBuilder builder, Element element) {
builder.addPropertyValue( builder.addPropertyValue(
@@ -57,5 +48,4 @@ public class IpInboundGatewayParser extends AbstractRemotingGatewayParser {
IpAdapterParserUtils.getMessageFormat(element)); IpAdapterParserUtils.getMessageFormat(element));
} }
} }

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder; 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; import org.springframework.util.StringUtils;
/** /**
@@ -27,7 +27,7 @@ import org.springframework.util.StringUtils;
* *
* @author Mark Fisher * @author Mark Fisher
*/ */
public class RmiInboundGatewayParser extends AbstractRemotingGatewayParser { public class RmiInboundGatewayParser extends AbstractInboundGatewayParser {
private static final String REMOTE_INVOCATION_EXECUTOR_ATTRIBUTE = "remote-invocation-executor"; private static final String REMOTE_INVOCATION_EXECUTOR_ATTRIBUTE = "remote-invocation-executor";

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -15,27 +15,29 @@
*/ */
package org.springframework.integration.ws.config; 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.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 * @author Iwein Fuld
*
*/ */
public class WebServiceInboundGatewayParser extends public class WebServiceInboundGatewayParser extends AbstractInboundGatewayParser {
AbstractRemotingGatewayParser {
@Override @Override
protected String getBeanClassName(Element element) { protected String getBeanClassName(Element element) {
String simpleClassName = (StringUtils.hasText(element String simpleClassName = (StringUtils.hasText(element.getAttribute("marshaller"))) ?
.getAttribute("marshaller"))) ? "MarshallingWebServiceInboundGateway" "MarshallingWebServiceInboundGateway" : "SimpleWebServiceInboundGateway";
: "SimpleWebServiceInboundGateway";
return "org.springframework.integration.ws." + simpleClassName; return "org.springframework.integration.ws." + simpleClassName;
} }
@Override
protected boolean isEligibleAttribute(String attributeName) {
return !(attributeName.endsWith("marshaller")) && super.isEligibleAttribute(attributeName);
}
@Override @Override
protected void doPostProcess(BeanDefinitionBuilder builder, Element element) { protected void doPostProcess(BeanDefinitionBuilder builder, Element element) {
String marshallerRef = element.getAttribute("marshaller"); 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);
}
} }

View File

@@ -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) {
}
}