SGF-508 - Fixup and polish Redis Server Java configuration meta-data using @Enable annotations.

This commit is contained in:
John Blum
2016-08-11 17:09:02 -07:00
parent 0dfbfdf443
commit c34067f6d4
2 changed files with 10 additions and 8 deletions

View File

@@ -50,13 +50,13 @@ public @interface EnableRedisServer {
*
* Defaults to {@literal localhost}.
*/
String bindAddress() default "localhost";
String bindAddress() default "";
/**
* Configures the Network port on which the Redis server will listen for Redis client connections.
*
* Defaults to {@literal 6379}.
*/
int port() default 6379;
int port() default RedisServerConfiguration.DEFAULT_REDIS_PORT;
}

View File

@@ -21,6 +21,7 @@ import java.util.Map;
import java.util.Properties;
import org.springframework.data.gemfire.config.annotation.support.EmbeddedServiceConfigurationSupport;
import org.springframework.data.gemfire.util.PropertiesBuilder;
/**
* The RedisServerConfiguration class is a Spring {@link org.springframework.context.annotation.ImportBeanDefinitionRegistrar}
@@ -28,11 +29,14 @@ import org.springframework.data.gemfire.config.annotation.support.EmbeddedServic
* an embedded Redis server.
*
* @author John Blum
* @see org.springframework.data.gemfire.config.annotation.EnableRedisServer
* @see org.springframework.data.gemfire.config.annotation.support.EmbeddedServiceConfigurationSupport
* @since 1.9.0
*/
public class RedisServerConfiguration extends EmbeddedServiceConfigurationSupport {
protected static final int DEFAULT_REDIS_PORT = 6379;
@Override
protected Class getAnnotationType() {
return EnableRedisServer.class;
@@ -40,11 +44,9 @@ public class RedisServerConfiguration extends EmbeddedServiceConfigurationSuppor
@Override
protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) {
Properties gemfireProperties = new Properties();
setProperty(gemfireProperties, "redis-bind-address", annotationAttributes.get("bindAddress"));
setProperty(gemfireProperties, "redis-port", annotationAttributes.get("port"));
return gemfireProperties;
return new PropertiesBuilder()
.setProperty("redis-bind-address", annotationAttributes.get("bindAddress"))
.setProperty("redis-port", resolvePort((Integer)annotationAttributes.get("port"), DEFAULT_REDIS_PORT))
.build();
}
}