Extract inner configuration property classes

Extract all inner @ConfigurationProperties classes from @Configuration
classes for consistency.
pull/313/merge
Phillip Webb 11 years ago
parent 5188ee5266
commit 8763fab0e7

@ -16,16 +16,12 @@
package org.springframework.boot.actuate.autoconfigure;
import java.util.Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.EndpointMBeanExportAutoConfiguration.EndpointMBeanExportProperties;
import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -61,49 +57,4 @@ public class EndpointMBeanExportAutoConfiguration {
return mbeanExporter;
}
@ConfigurationProperties(name = "endpoints.jmx")
public static class EndpointMBeanExportProperties {
private String domain;
private boolean uniqueNames = false;
private boolean enabled = true;
private Properties staticNames = new Properties();
public boolean isEnabled() {
return this.enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getDomain() {
return this.domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public boolean isUniqueNames() {
return this.uniqueNames;
}
public void setUniqueNames(boolean uniqueNames) {
this.uniqueNames = uniqueNames;
}
public Properties getStaticNames() {
return this.staticNames;
}
public void setStaticNames(String[] staticNames) {
this.staticNames = StringUtils.splitArrayElementsIntoProperties(staticNames,
"=");
}
}
}

@ -0,0 +1,71 @@
/*
* Copyright 2012-2014 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.boot.actuate.autoconfigure;
import java.util.Properties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;
/**
* Configuration properties for JMX.
*
* @author Christian Dupuis
*/
@ConfigurationProperties(name = "endpoints.jmx")
public class EndpointMBeanExportProperties {
private String domain;
private boolean uniqueNames = false;
private boolean enabled = true;
private Properties staticNames = new Properties();
public boolean isEnabled() {
return this.enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getDomain() {
return this.domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public boolean isUniqueNames() {
return this.uniqueNames;
}
public void setUniqueNames(boolean uniqueNames) {
this.uniqueNames = uniqueNames;
}
public Properties getStaticNames() {
return this.staticNames;
}
public void setStaticNames(String[] staticNames) {
this.staticNames = StringUtils.splitArrayElementsIntoProperties(staticNames, "=");
}
}

@ -16,13 +16,10 @@
package org.springframework.boot.actuate.autoconfigure;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.jolokia.http.AgentServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.JolokiaAutoConfiguration.JolokiaProperties;
import org.springframework.boot.actuate.endpoint.mvc.JolokiaMvcEndpoint;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
@ -32,7 +29,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -81,18 +77,4 @@ public class JolokiaAutoConfiguration {
return initParameters;
}
@ConfigurationProperties(name = "jolokia")
public static class JolokiaProperties {
private Map<String, String> config = new HashMap<String, String>();
public Map<String, String> getConfig() {
return this.config;
}
public void setConfig(Map<String, String> config) {
this.config = config;
}
}
}

@ -0,0 +1,42 @@
/*
* Copyright 2012-2014 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.boot.actuate.autoconfigure;
import java.util.HashMap;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Configuration properties for Jolokia.
*
* @author Christian Dupuis
* @author Dave Syer
*/
@ConfigurationProperties(name = "jolokia")
public class JolokiaProperties {
private Map<String, String> config = new HashMap<String, String>();
public Map<String, String> getConfig() {
return this.config;
}
public void setConfig(Map<String, String> config) {
this.config = config;
}
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -23,11 +23,9 @@ import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration.RabbitConnectionFactoryProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -41,7 +39,7 @@ import com.rabbitmq.client.Channel;
*/
@Configuration
@ConditionalOnClass({ RabbitTemplate.class, Channel.class })
@EnableConfigurationProperties(RabbitConnectionFactoryProperties.class)
@EnableConfigurationProperties(RabbitProperties.class)
public class RabbitAutoConfiguration {
@Bean
@ -66,7 +64,7 @@ public class RabbitAutoConfiguration {
@Bean
public ConnectionFactory rabbitConnectionFactory(
RabbitConnectionFactoryProperties config) {
RabbitProperties config) {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
config.getHost());
connectionFactory.setPort(config.getPort());
@ -82,72 +80,4 @@ public class RabbitAutoConfiguration {
return connectionFactory;
}
}
@ConfigurationProperties(name = "spring.rabbitmq")
public static class RabbitConnectionFactoryProperties {
private String host = "localhost";
private int port = 5672;
private String username;
private String password;
private String virtualHost;
private boolean dynamic = true;
public String getHost() {
return this.host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return this.port;
}
public void setPort(int port) {
this.port = port;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean isDynamic() {
return this.dynamic;
}
public void setDynamic(boolean dynamic) {
this.dynamic = dynamic;
}
public String getVirtualHost() {
return this.virtualHost;
}
public void setVirtualHost(String virtualHost) {
while (virtualHost.startsWith("/") && virtualHost.length() > 0) {
virtualHost = virtualHost.substring(1);
}
this.virtualHost = "/" + virtualHost;
}
}
}

@ -0,0 +1,92 @@
/*
* Copyright 2012-2014 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.boot.autoconfigure.amqp;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Configuration properties for Rabbit.
*
* @author Greg Turnquist
*/
@ConfigurationProperties(name = "spring.rabbitmq")
public class RabbitProperties {
private String host = "localhost";
private int port = 5672;
private String username;
private String password;
private String virtualHost;
private boolean dynamic = true;
public String getHost() {
return this.host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return this.port;
}
public void setPort(int port) {
this.port = port;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean isDynamic() {
return this.dynamic;
}
public void setDynamic(boolean dynamic) {
this.dynamic = dynamic;
}
public String getVirtualHost() {
return this.virtualHost;
}
public void setVirtualHost(String virtualHost) {
while (virtualHost.startsWith("/") && virtualHost.length() > 0) {
virtualHost = virtualHost.substring(1);
}
this.virtualHost = "/" + virtualHost;
}
}

@ -0,0 +1,62 @@
/*
* Copyright 2012-2014 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.boot.autoconfigure.jms;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Configuration properties for ActiveMQ
* @author Greg Turnquist
*/
@ConfigurationProperties(name = "spring.activemq")
public class ActiveMQProperties {
private String brokerURL = "tcp://localhost:61616";
private boolean inMemory = true;
private boolean pooled = false;
// Will override brokerURL if inMemory is set to true
public String getBrokerURL() {
if (this.inMemory) {
return "vm://localhost";
}
return this.brokerURL;
}
public void setBrokerURL(String brokerURL) {
this.brokerURL = brokerURL;
}
public boolean isInMemory() {
return this.inMemory;
}
public void setInMemory(boolean inMemory) {
this.inMemory = inMemory;
}
public boolean isPooled() {
return this.pooled;
}
public void setPooled(boolean pooled) {
this.pooled = pooled;
}
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -73,11 +73,11 @@ public class JmsTemplateAutoConfiguration {
@Configuration
@ConditionalOnClass(ActiveMQConnectionFactory.class)
@ConditionalOnMissingBean(ConnectionFactory.class)
@EnableConfigurationProperties(ActiveMQConnectionFactoryProperties.class)
@EnableConfigurationProperties(ActiveMQProperties.class)
protected static class ActiveMQConnectionFactoryCreator {
@Autowired
private ActiveMQConnectionFactoryProperties config;
private ActiveMQProperties config;
@Bean
public ConnectionFactory jmsConnectionFactory() {
@ -92,43 +92,4 @@ public class JmsTemplateAutoConfiguration {
}
@ConfigurationProperties(name = "spring.activemq")
public static class ActiveMQConnectionFactoryProperties {
private String brokerURL = "tcp://localhost:61616";
private boolean inMemory = true;
private boolean pooled = false;
// Will override brokerURL if inMemory is set to true
public String getBrokerURL() {
if (this.inMemory) {
return "vm://localhost";
}
return this.brokerURL;
}
public void setBrokerURL(String brokerURL) {
this.brokerURL = brokerURL;
}
public boolean isInMemory() {
return this.inMemory;
}
public void setInMemory(boolean inMemory) {
this.inMemory = inMemory;
}
public boolean isPooled() {
return this.pooled;
}
public void setPooled(boolean pooled) {
this.pooled = pooled;
}
}
}

@ -24,7 +24,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -147,92 +146,4 @@ public class RedisAutoConfiguration {
}
@ConfigurationProperties(name = "spring.redis")
public static class RedisProperties {
private String host = "localhost";
private String password;
private int port = 6379;
private Pool pool;
public String getHost() {
return this.host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return this.port;
}
public void setPort(int port) {
this.port = port;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public Pool getPool() {
return this.pool;
}
public void setPool(Pool pool) {
this.pool = pool;
}
public static class Pool {
private int maxIdle = 8;
private int minIdle = 0;
private int maxActive = 8;
private int maxWait = -1;
public int getMaxIdle() {
return this.maxIdle;
}
public void setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
public int getMinIdle() {
return this.minIdle;
}
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
public int getMaxActive() {
return this.maxActive;
}
public void setMaxActive(int maxActive) {
this.maxActive = maxActive;
}
public int getMaxWait() {
return this.maxWait;
}
public void setMaxWait(int maxWait) {
this.maxWait = maxWait;
}
}
}
}

@ -0,0 +1,115 @@
/*
* Copyright 2012-2014 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.boot.autoconfigure.redis;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Configuration properties for Redis.
*
* @author Dave Syer
*/
@ConfigurationProperties(name = "spring.redis")
public class RedisProperties {
private String host = "localhost";
private String password;
private int port = 6379;
private RedisProperties.Pool pool;
public String getHost() {
return this.host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return this.port;
}
public void setPort(int port) {
this.port = port;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public RedisProperties.Pool getPool() {
return this.pool;
}
public void setPool(RedisProperties.Pool pool) {
this.pool = pool;
}
/**
* Pool properties.
*/
public static class Pool {
private int maxIdle = 8;
private int minIdle = 0;
private int maxActive = 8;
private int maxWait = -1;
public int getMaxIdle() {
return this.maxIdle;
}
public void setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
public int getMinIdle() {
return this.minIdle;
}
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
public int getMaxActive() {
return this.maxActive;
}
public void setMaxActive(int maxActive) {
this.maxActive = maxActive;
}
public int getMaxWait() {
return this.maxWait;
}
public void setMaxWait(int maxWait) {
this.maxWait = maxWait;
}
}
}

@ -0,0 +1,37 @@
/*
* Copyright 2012-2014 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.boot.autoconfigure.web;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.http.converter.HttpMessageConverter;
/**
* Configuration properties to configure {@link HttpMessageConverter}s.
*/
@ConfigurationProperties(name = "http.mappers", ignoreUnknownFields = false)
public class HttpMapperProperties {
private boolean jsonPrettyPrint = false;
public void setJsonPrettyPrint(boolean jsonPrettyPrint) {
this.jsonPrettyPrint = jsonPrettyPrint;
}
public boolean isJsonPrettyPrint() {
return this.jsonPrettyPrint;
}
}

@ -29,7 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -63,11 +62,11 @@ public class HttpMessageConvertersAutoConfiguration {
@Configuration
@ConditionalOnClass(ObjectMapper.class)
@EnableConfigurationProperties(ObjectMappersProperties.class)
@EnableConfigurationProperties(HttpMapperProperties.class)
protected static class ObjectMappers {
@Autowired
private ObjectMappersProperties properties = new ObjectMappersProperties();
private HttpMapperProperties properties = new HttpMapperProperties();
@Autowired
private ListableBeanFactory beanFactory;
@ -103,21 +102,4 @@ public class HttpMessageConvertersAutoConfiguration {
}
/**
* {@link ConfigurationProperties} to configure {@link HttpMessageConverter}s.
*/
@ConfigurationProperties(name = "http.mappers", ignoreUnknownFields = false)
public static class ObjectMappersProperties {
private boolean jsonPrettyPrint = false;
public void setJsonPrettyPrint(boolean jsonPrettyPrint) {
this.jsonPrettyPrint = jsonPrettyPrint;
}
public boolean isJsonPrettyPrint() {
return this.jsonPrettyPrint;
}
}
}

Loading…
Cancel
Save