diff --git a/src/main/java/org/springframework/data/gemfire/config/GatewayReceiverParser.java b/src/main/java/org/springframework/data/gemfire/config/GatewayReceiverParser.java index 085990c3..a404b9dc 100644 --- a/src/main/java/org/springframework/data/gemfire/config/GatewayReceiverParser.java +++ b/src/main/java/org/springframework/data/gemfire/config/GatewayReceiverParser.java @@ -23,9 +23,12 @@ import org.springframework.util.StringUtils; import org.w3c.dom.Element; /** + * Spring BeanDefinitionParser for the <gfe:gateway-receiver> SDG (GFE) XML XSD namespace element. + * * @author David Turanski * @author John Blum * @see org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser + * @see org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean */ class GatewayReceiverParser extends AbstractSimpleBeanDefinitionParser { @@ -43,6 +46,7 @@ class GatewayReceiverParser extends AbstractSimpleBeanDefinitionParser { builder.setLazyInit(false); ParsingUtils.setPropertyValue(element, builder, "bind-address"); + ParsingUtils.setPropertyValue(element, builder, "hostname-for-senders"); ParsingUtils.setPropertyValue(element, builder, "start-port"); ParsingUtils.setPropertyValue(element, builder, "end-port"); ParsingUtils.setPropertyValue(element, builder, "manual-start"); diff --git a/src/main/java/org/springframework/data/gemfire/wan/GatewayReceiverFactoryBean.java b/src/main/java/org/springframework/data/gemfire/wan/GatewayReceiverFactoryBean.java index 0d976a50..a0ab9f41 100644 --- a/src/main/java/org/springframework/data/gemfire/wan/GatewayReceiverFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/wan/GatewayReceiverFactoryBean.java @@ -26,18 +26,21 @@ import com.gemstone.gemfire.cache.Cache; import com.gemstone.gemfire.cache.wan.GatewayReceiver; import com.gemstone.gemfire.cache.wan.GatewayReceiverFactory; import com.gemstone.gemfire.cache.wan.GatewayTransportFilter; +import com.gemstone.gemfire.management.internal.cli.util.spring.StringUtils; /** - * FactoryBean for creating a GemFire {@link GatewayReceiver}. + * Spring FactoryBean for creating a GemFire {@link GatewayReceiver}. * * @author David Turanski * @author John Blum + * @see org.springframework.context.SmartLifecycle * @see org.springframework.data.gemfire.wan.AbstractWANComponentFactoryBean * @see com.gemstone.gemfire.cache.Cache * @see com.gemstone.gemfire.cache.wan.GatewayReceiver * @see com.gemstone.gemfire.cache.wan.GatewayReceiverFactory * @since 1.2.2 */ +@SuppressWarnings("unused") public class GatewayReceiverFactoryBean extends AbstractWANComponentFactoryBean implements SmartLifecycle { @@ -53,6 +56,7 @@ public class GatewayReceiverFactoryBean extends AbstractWANComponentFactoryBean< private List transportFilters; private String bindAddress; + private String hostnameForSenders; /** * Constructs an instance of the GatewayReceiverFactoryBean class for configuring an initializing @@ -84,17 +88,22 @@ public class GatewayReceiverFactoryBean extends AbstractWANComponentFactoryBean< } } - if (bindAddress != null) { + if (StringUtils.hasText(bindAddress)) { gatewayReceiverFactory.setBindAddress(bindAddress); } - int minPort = (startPort != null ? startPort : GatewayReceiver.DEFAULT_START_PORT); - int maxPort = (endPort != null ? endPort : GatewayReceiver.DEFAULT_END_PORT); + if (StringUtils.hasText(hostnameForSenders)) { + gatewayReceiverFactory.setHostnameForSenders(hostnameForSenders); + } - Assert.isTrue(minPort <= maxPort, String.format("'startPort' must be less than or equal to %1$d.", maxPort)); + int localStartPort = (startPort != null ? startPort : GatewayReceiver.DEFAULT_START_PORT); + int localEndPort = (endPort != null ? endPort : GatewayReceiver.DEFAULT_END_PORT); - gatewayReceiverFactory.setStartPort(minPort); - gatewayReceiverFactory.setEndPort(maxPort); + Assert.isTrue(localStartPort <= localEndPort, String.format("'startPort' must be less than or equal to %1$d.", + localEndPort)); + + gatewayReceiverFactory.setStartPort(localStartPort); + gatewayReceiverFactory.setEndPort(localEndPort); if (maximumTimeBetweenPings != null) { gatewayReceiverFactory.setMaximumTimeBetweenPings(maximumTimeBetweenPings); @@ -115,6 +124,10 @@ public class GatewayReceiverFactoryBean extends AbstractWANComponentFactoryBean< this.bindAddress = bindAddress; } + public void setHostnameForSenders(String hostnameForSenders) { + this.hostnameForSenders = hostnameForSenders; + } + public void setStartPort(Integer startPort) { this.startPort = startPort; } diff --git a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.4.xsd b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.4.xsd index 75c5a27e..200e8b6f 100644 --- a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.4.xsd +++ b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.4.xsd @@ -2599,6 +2599,16 @@ Specifies the bind address (IP address or host name) for the gateway receiver ]]> + + + + + + + + + + + + + + + - + + GatewayReceiverNamespaceTest + 0 + config + - + + +