Commit 80f2336f authored by Phillip Webb's avatar Phillip Webb

Polish

parent 65b6cf8b
...@@ -30,7 +30,6 @@ import org.springframework.util.Assert; ...@@ -30,7 +30,6 @@ import org.springframework.util.Assert;
* A value object representing an audit event: at a particular time, a particular user or * A value object representing an audit event: at a particular time, a particular user or
* agent carried out an action of a particular type. This object records the details of * agent carried out an action of a particular type. This object records the details of
* such an event. * such an event.
*
* <p> * <p>
* Users can inject a {@link AuditEventRepository} to publish their own events or * Users can inject a {@link AuditEventRepository} to publish their own events or
* alternatively use Springs {@link AuthenticationEventPublisher} (usually obtained by * alternatively use Springs {@link AuthenticationEventPublisher} (usually obtained by
......
...@@ -63,21 +63,22 @@ public class RabbitAutoConfiguration { ...@@ -63,21 +63,22 @@ public class RabbitAutoConfiguration {
protected static class RabbitConnectionFactoryCreator { protected static class RabbitConnectionFactoryCreator {
@Bean @Bean
public ConnectionFactory rabbitConnectionFactory( public ConnectionFactory rabbitConnectionFactory(RabbitProperties config) {
RabbitProperties config) { CachingConnectionFactory factory = new CachingConnectionFactory(
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
config.getHost()); config.getHost());
connectionFactory.setPort(config.getPort()); factory.setPort(config.getPort());
if (config.getUsername() != null) { if (config.getUsername() != null) {
connectionFactory.setUsername(config.getUsername()); factory.setUsername(config.getUsername());
} }
if (config.getPassword() != null) { if (config.getPassword() != null) {
connectionFactory.setPassword(config.getPassword()); factory.setPassword(config.getPassword());
} }
if (config.getVirtualHost() != null) { if (config.getVirtualHost() != null) {
connectionFactory.setVirtualHost(config.getVirtualHost()); factory.setVirtualHost(config.getVirtualHost());
} }
return connectionFactory; return factory;
} }
} }
} }
...@@ -77,4 +77,5 @@ public class BatchDatabaseInitializer implements EnvironmentAware { ...@@ -77,4 +77,5 @@ public class BatchDatabaseInitializer implements EnvironmentAware {
DatabasePopulatorUtils.execute(populator, this.dataSource); DatabasePopulatorUtils.execute(populator, this.dataSource);
} }
} }
} }
...@@ -39,4 +39,5 @@ public @interface ConditionalOnExpression { ...@@ -39,4 +39,5 @@ public @interface ConditionalOnExpression {
* condition passes or {@code false} if it fails. * condition passes or {@code false} if it fails.
*/ */
String value() default "true"; String value() default "true";
} }
...@@ -35,4 +35,5 @@ import org.springframework.context.annotation.Conditional; ...@@ -35,4 +35,5 @@ import org.springframework.context.annotation.Conditional;
@Documented @Documented
@Conditional(OnWebApplicationCondition.class) @Conditional(OnWebApplicationCondition.class)
public @interface ConditionalOnNotWebApplication { public @interface ConditionalOnNotWebApplication {
} }
...@@ -41,4 +41,5 @@ public @interface ConditionalOnResource { ...@@ -41,4 +41,5 @@ public @interface ConditionalOnResource {
* @return the resource paths that must be present. * @return the resource paths that must be present.
*/ */
public String[] resources() default {}; public String[] resources() default {};
} }
...@@ -292,5 +292,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit ...@@ -292,5 +292,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
string.append(")"); string.append(")");
return string.toString(); return string.toString();
} }
} }
} }
...@@ -124,4 +124,5 @@ class OnClassCondition extends SpringBootCondition { ...@@ -124,4 +124,5 @@ class OnClassCondition extends SpringBootCondition {
public abstract boolean matches(String className, ConditionContext context); public abstract boolean matches(String className, ConditionContext context);
}; };
} }
...@@ -76,4 +76,5 @@ class OnWebApplicationCondition extends SpringBootCondition { ...@@ -76,4 +76,5 @@ class OnWebApplicationCondition extends SpringBootCondition {
return ConditionOutcome.noMatch("not a web application"); return ConditionOutcome.noMatch("not a web application");
} }
} }
...@@ -49,6 +49,7 @@ class MongoRepositoriesAutoConfigureRegistrar extends ...@@ -49,6 +49,7 @@ class MongoRepositoriesAutoConfigureRegistrar extends
@EnableMongoRepositories @EnableMongoRepositories
private static class EnableMongoRepositoriesConfiguration { private static class EnableMongoRepositoriesConfiguration {
} }
} }
...@@ -43,12 +43,12 @@ import com.mongodb.Mongo; ...@@ -43,12 +43,12 @@ import com.mongodb.Mongo;
public class MongoTemplateAutoConfiguration { public class MongoTemplateAutoConfiguration {
@Autowired @Autowired
private MongoProperties config; private MongoProperties properties;
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public MongoTemplate mongoTemplate(Mongo mongo) throws UnknownHostException { public MongoTemplate mongoTemplate(Mongo mongo) throws UnknownHostException {
return new MongoTemplate(mongo, this.config.getMongoClientDatabase()); return new MongoTemplate(mongo, this.properties.getMongoClientDatabase());
} }
} }
...@@ -142,18 +142,21 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { ...@@ -142,18 +142,21 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
@ConditionalOnMissingBean(DataSource.class) @ConditionalOnMissingBean(DataSource.class)
@Import(EmbeddedDataSourceConfiguration.class) @Import(EmbeddedDataSourceConfiguration.class)
protected static class EmbeddedConfiguration { protected static class EmbeddedConfiguration {
} }
@Conditional(DataSourceAutoConfiguration.TomcatDatabaseCondition.class) @Conditional(DataSourceAutoConfiguration.TomcatDatabaseCondition.class)
@ConditionalOnMissingBean(DataSource.class) @ConditionalOnMissingBean(DataSource.class)
@Import(TomcatDataSourceConfiguration.class) @Import(TomcatDataSourceConfiguration.class)
protected static class TomcatConfiguration { protected static class TomcatConfiguration {
} }
@Conditional(DataSourceAutoConfiguration.BasicDatabaseCondition.class) @Conditional(DataSourceAutoConfiguration.BasicDatabaseCondition.class)
@ConditionalOnMissingBean(DataSource.class) @ConditionalOnMissingBean(DataSource.class)
@Import(CommonsDataSourceConfiguration.class) @Import(CommonsDataSourceConfiguration.class)
protected static class DbcpConfiguration { protected static class DbcpConfiguration {
} }
@Configuration @Configuration
...@@ -244,6 +247,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { ...@@ -244,6 +247,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
} }
return url; return url;
} }
} }
/** /**
...@@ -267,6 +271,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { ...@@ -267,6 +271,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
} }
return super.getMatchOutcome(context, metadata); return super.getMatchOutcome(context, metadata);
} }
} }
/** /**
...@@ -304,6 +309,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { ...@@ -304,6 +309,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
} }
return ConditionOutcome.match("embedded database " + type + " detected"); return ConditionOutcome.match("embedded database " + type + " detected");
} }
} }
/** /**
...@@ -334,5 +340,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { ...@@ -334,5 +340,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
return ConditionOutcome.noMatch("no existing bean configured database"); return ConditionOutcome.noMatch("no existing bean configured database");
} }
} }
} }
...@@ -121,4 +121,5 @@ public enum EmbeddedDatabaseConnection { ...@@ -121,4 +121,5 @@ public enum EmbeddedDatabaseConnection {
} }
return NONE; return NONE;
} }
} }
...@@ -42,7 +42,7 @@ import org.springframework.jms.core.JmsTemplate; ...@@ -42,7 +42,7 @@ import org.springframework.jms.core.JmsTemplate;
public class JmsTemplateAutoConfiguration { public class JmsTemplateAutoConfiguration {
@Autowired @Autowired
private JmsTemplateProperties config; private JmsTemplateProperties properties;
@Autowired @Autowired
private ConnectionFactory connectionFactory; private ConnectionFactory connectionFactory;
...@@ -51,7 +51,7 @@ public class JmsTemplateAutoConfiguration { ...@@ -51,7 +51,7 @@ public class JmsTemplateAutoConfiguration {
@ConditionalOnMissingBean(JmsTemplate.class) @ConditionalOnMissingBean(JmsTemplate.class)
public JmsTemplate jmsTemplate() { public JmsTemplate jmsTemplate() {
JmsTemplate jmsTemplate = new JmsTemplate(this.connectionFactory); JmsTemplate jmsTemplate = new JmsTemplate(this.connectionFactory);
jmsTemplate.setPubSubDomain(this.config.isPubSubDomain()); jmsTemplate.setPubSubDomain(this.properties.isPubSubDomain());
return jmsTemplate; return jmsTemplate;
} }
......
...@@ -41,6 +41,7 @@ public class JmxAutoConfiguration { ...@@ -41,6 +41,7 @@ public class JmxAutoConfiguration {
@Configuration @Configuration
@EnableMBeanExport(defaultDomain = "${spring.jmx.default_domain:}", server = "${spring.jmx.server:}") @EnableMBeanExport(defaultDomain = "${spring.jmx.default_domain:}", server = "${spring.jmx.server:}")
public static class MBeanExport { public static class MBeanExport {
} }
} }
...@@ -176,5 +176,7 @@ public class AutoConfigurationReportLoggingInitializer implements ...@@ -176,5 +176,7 @@ public class AutoConfigurationReportLoggingInitializer implements
public void onApplicationEvent(ApplicationEvent event) { public void onApplicationEvent(ApplicationEvent event) {
AutoConfigurationReportLoggingInitializer.this.onApplicationEvent(event); AutoConfigurationReportLoggingInitializer.this.onApplicationEvent(event);
} }
} }
} }
...@@ -43,7 +43,7 @@ import com.mongodb.Mongo; ...@@ -43,7 +43,7 @@ import com.mongodb.Mongo;
public class MongoAutoConfiguration { public class MongoAutoConfiguration {
@Autowired @Autowired
private MongoProperties config; private MongoProperties properties;
private Mongo mongo; private Mongo mongo;
...@@ -57,7 +57,7 @@ public class MongoAutoConfiguration { ...@@ -57,7 +57,7 @@ public class MongoAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public Mongo mongo() throws UnknownHostException { public Mongo mongo() throws UnknownHostException {
this.mongo = this.config.createMongoClient(); this.mongo = this.properties.createMongoClient();
return this.mongo; return this.mongo;
} }
} }
...@@ -54,15 +54,15 @@ public class RedisAutoConfiguration { ...@@ -54,15 +54,15 @@ public class RedisAutoConfiguration {
protected static class RedisConnectionConfiguration { protected static class RedisConnectionConfiguration {
@Autowired @Autowired
private RedisProperties config; private RedisProperties properties;
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
RedisConnectionFactory redisConnectionFactory() throws UnknownHostException { RedisConnectionFactory redisConnectionFactory() throws UnknownHostException {
LettuceConnectionFactory factory = new LettuceConnectionFactory( LettuceConnectionFactory factory = new LettuceConnectionFactory(
this.config.getHost(), this.config.getPort()); this.properties.getHost(), this.properties.getPort());
if (this.config.getPassword() != null) { if (this.properties.getPassword() != null) {
factory.setPassword(this.config.getPassword()); factory.setPassword(this.properties.getPassword());
} }
return factory; return factory;
} }
...@@ -74,20 +74,20 @@ public class RedisAutoConfiguration { ...@@ -74,20 +74,20 @@ public class RedisAutoConfiguration {
protected static class RedisPooledConnectionConfiguration { protected static class RedisPooledConnectionConfiguration {
@Autowired @Autowired
private RedisProperties config; private RedisProperties properties;
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
RedisConnectionFactory redisConnectionFactory() throws UnknownHostException { RedisConnectionFactory redisConnectionFactory() throws UnknownHostException {
if (this.config.getPool() != null) { if (this.properties.getPool() != null) {
LettuceConnectionFactory factory = new LettuceConnectionFactory( LettuceConnectionFactory factory = new LettuceConnectionFactory(
lettucePool()); lettucePool());
return factory; return factory;
} }
LettuceConnectionFactory factory = new LettuceConnectionFactory( LettuceConnectionFactory factory = new LettuceConnectionFactory(
this.config.getHost(), this.config.getPort()); this.properties.getHost(), this.properties.getPort());
if (this.config.getPassword() != null) { if (this.properties.getPassword() != null) {
factory.setPassword(this.config.getPassword()); factory.setPassword(this.properties.getPassword());
} }
return factory; return factory;
} }
...@@ -95,13 +95,13 @@ public class RedisAutoConfiguration { ...@@ -95,13 +95,13 @@ public class RedisAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public LettucePool lettucePool() { public LettucePool lettucePool() {
return new DefaultLettucePool(this.config.getHost(), this.config.getPort(), return new DefaultLettucePool(this.properties.getHost(),
poolConfig()); this.properties.getPort(), poolConfig());
} }
private PoolConfig poolConfig() { private PoolConfig poolConfig() {
PoolConfig pool = new PoolConfig(); PoolConfig pool = new PoolConfig();
RedisProperties.Pool props = this.config.getPool(); RedisProperties.Pool props = this.properties.getPool();
if (props != null) { if (props != null) {
pool.setMaxActive(props.getMaxActive()); pool.setMaxActive(props.getMaxActive());
pool.setMaxIdle(props.getMaxIdle()); pool.setMaxIdle(props.getMaxIdle());
...@@ -110,19 +110,22 @@ public class RedisAutoConfiguration { ...@@ -110,19 +110,22 @@ public class RedisAutoConfiguration {
} }
return pool; return pool;
} }
} }
@Bean(name = "org.springframework.autoconfigure.redis.RedisProperties") @Bean(name = "org.springframework.autoconfigure.redis.RedisProperties")
@ConditionalOnMissingBean @ConditionalOnMissingBean
public RedisProperties redisProperties() { public RedisProperties redisProperties() {
return new RedisProperties(); return new RedisProperties();
} }
@Configuration @Configuration
protected static class RedisConfiguration { protected static class RedisConfiguration {
@Autowired @Autowired
private RedisProperties config; private RedisProperties properties;
@Bean @Bean
@ConditionalOnMissingBean(name = "redisTemplate") @ConditionalOnMissingBean(name = "redisTemplate")
......
...@@ -66,7 +66,6 @@ import org.springframework.web.servlet.support.RequestDataValueProcessor; ...@@ -66,7 +66,6 @@ import org.springframework.web.servlet.support.RequestDataValueProcessor;
* password=password)</code> but can easily be customized by providing a bean definition * password=password)</code> but can easily be customized by providing a bean definition
* of type {@link AuthenticationManager}. Also provides audit logging of authentication * of type {@link AuthenticationManager}. Also provides audit logging of authentication
* events. * events.
*
* <p> * <p>
* Some common simple customizations: * Some common simple customizations:
* <ul> * <ul>
...@@ -168,6 +167,7 @@ public class SpringBootWebSecurityConfiguration { ...@@ -168,6 +167,7 @@ public class SpringBootWebSecurityConfiguration {
@Configuration @Configuration
@EnableWebMvcSecurity @EnableWebMvcSecurity
protected static class DefaultWebMvcSecurityConfiguration { protected static class DefaultWebMvcSecurityConfiguration {
} }
} }
...@@ -179,6 +179,7 @@ public class SpringBootWebSecurityConfiguration { ...@@ -179,6 +179,7 @@ public class SpringBootWebSecurityConfiguration {
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
protected static class DefaultWebSecurityConfiguration { protected static class DefaultWebSecurityConfiguration {
} }
@ConditionalOnExpression("${security.basic.enabled:true}") @ConditionalOnExpression("${security.basic.enabled:true}")
......
...@@ -56,6 +56,7 @@ import org.thymeleaf.templateresolver.TemplateResolver; ...@@ -56,6 +56,7 @@ import org.thymeleaf.templateresolver.TemplateResolver;
public class ThymeleafAutoConfiguration { public class ThymeleafAutoConfiguration {
public static final String DEFAULT_PREFIX = "classpath:/templates/"; public static final String DEFAULT_PREFIX = "classpath:/templates/";
public static final String DEFAULT_SUFFIX = ".html"; public static final String DEFAULT_SUFFIX = ".html";
@Configuration @Configuration
...@@ -108,7 +109,8 @@ public class ThymeleafAutoConfiguration { ...@@ -108,7 +109,8 @@ public class ThymeleafAutoConfiguration {
protected static class ThymeleafDefaultConfiguration { protected static class ThymeleafDefaultConfiguration {
@Autowired @Autowired
private final Collection<ITemplateResolver> templateResolvers = Collections.emptySet(); private final Collection<ITemplateResolver> templateResolvers = Collections
.emptySet();
@Autowired(required = false) @Autowired(required = false)
private final Collection<IDialect> dialects = Collections.emptySet(); private final Collection<IDialect> dialects = Collections.emptySet();
......
...@@ -97,6 +97,7 @@ public class DispatcherServletAutoConfiguration { ...@@ -97,6 +97,7 @@ public class DispatcherServletAutoConfiguration {
.match("one or more DispatcherServlets found and none is named " .match("one or more DispatcherServlets found and none is named "
+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME); + DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
} }
} }
} }
...@@ -120,6 +120,7 @@ public class EmbeddedServletContainerAutoConfiguration { ...@@ -120,6 +120,7 @@ public class EmbeddedServletContainerAutoConfiguration {
} }
} }
} }
} }
...@@ -34,4 +34,5 @@ public class HttpMapperProperties { ...@@ -34,4 +34,5 @@ public class HttpMapperProperties {
public boolean isJsonPrettyPrint() { public boolean isJsonPrettyPrint() {
return this.jsonPrettyPrint; return this.jsonPrettyPrint;
} }
} }
...@@ -238,6 +238,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer { ...@@ -238,6 +238,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer {
factory.addContextValves(valve); factory.addContextValves(valve);
} }
} }
} }
} }
...@@ -116,6 +116,7 @@ public class WebSocketAutoConfiguration { ...@@ -116,6 +116,7 @@ public class WebSocketAutoConfiguration {
@Configuration @Configuration
@ConditionalOnClass(name = "org.apache.tomcat.websocket.server.WsSci") @ConditionalOnClass(name = "org.apache.tomcat.websocket.server.WsSci")
protected static class TomcatWebSocketConfiguration { protected static class TomcatWebSocketConfiguration {
@Bean @Bean
public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() { public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory() { TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory() {
...@@ -130,6 +131,7 @@ public class WebSocketAutoConfiguration { ...@@ -130,6 +131,7 @@ public class WebSocketAutoConfiguration {
}; };
return factory; return factory;
} }
} }
} }
...@@ -43,25 +43,18 @@ public class RelaxedDataBinder extends DataBinder { ...@@ -43,25 +43,18 @@ public class RelaxedDataBinder extends DataBinder {
private String namePrefix; private String namePrefix;
private boolean ignoreNestedProperties = false; private boolean ignoreNestedProperties;
/** /**
* Create a new {@link RelaxedDataBinder} instance.
* @param target the target into which properties are bound * @param target the target into which properties are bound
*/ */
public RelaxedDataBinder(Object target) { public RelaxedDataBinder(Object target) {
super(wrapTarget(target)); super(wrapTarget(target));
} }
private static Object wrapTarget(Object target) {
if (target instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) target;
target = new MapHolder(map);
}
return target;
}
/** /**
* Create a new {@link RelaxedDataBinder} instance.
* @param target the target into which properties are bound * @param target the target into which properties are bound
* @param namePrefix An optional prefix to be used when reading properties * @param namePrefix An optional prefix to be used when reading properties
*/ */
...@@ -131,13 +124,13 @@ public class RelaxedDataBinder extends DataBinder { ...@@ -131,13 +124,13 @@ public class RelaxedDataBinder extends DataBinder {
return propertyValues; return propertyValues;
} }
MutablePropertyValues rtn = new MutablePropertyValues(); MutablePropertyValues rtn = new MutablePropertyValues();
for (PropertyValue pv : propertyValues.getPropertyValues()) { for (PropertyValue value : propertyValues.getPropertyValues()) {
String name = pv.getName(); String name = value.getName();
for (String candidate : new RelaxedNames(this.namePrefix)) { for (String candidate : new RelaxedNames(this.namePrefix)) {
if (name.startsWith(candidate)) { if (name.startsWith(candidate)) {
name = name.substring(candidate.length()); name = name.substring(candidate.length());
if (!(this.ignoreNestedProperties && name.contains("."))) { if (!(this.ignoreNestedProperties && name.contains("."))) {
rtn.add(name, pv.getValue()); rtn.add(name, value.getValue());
} }
} }
} }
...@@ -211,7 +204,6 @@ public class RelaxedDataBinder extends DataBinder { ...@@ -211,7 +204,6 @@ public class RelaxedDataBinder extends DataBinder {
} }
return initializePath(wrapper, path, index); return initializePath(wrapper, path, index);
} }
private void extendCollectionIfNecessary(BeanWrapper wrapper, BeanPath path, int index) { private void extendCollectionIfNecessary(BeanWrapper wrapper, BeanPath path, int index) {
...@@ -262,7 +254,20 @@ public class RelaxedDataBinder extends DataBinder { ...@@ -262,7 +254,20 @@ public class RelaxedDataBinder extends DataBinder {
return name; return name;
} }
private static Object wrapTarget(Object target) {
if (target instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) target;
target = new MapHolder(map);
}
return target;
}
/**
* Holder to allow Map targets to be bound.
*/
static class MapHolder { static class MapHolder {
private Map<String, Object> map; private Map<String, Object> map;
public MapHolder(Map<String, Object> map) { public MapHolder(Map<String, Object> map) {
...@@ -276,6 +281,7 @@ public class RelaxedDataBinder extends DataBinder { ...@@ -276,6 +281,7 @@ public class RelaxedDataBinder extends DataBinder {
public Map<String, Object> getMap() { public Map<String, Object> getMap() {
return this.map; return this.map;
} }
} }
private static class BeanPath { private static class BeanPath {
...@@ -286,6 +292,29 @@ public class RelaxedDataBinder extends DataBinder { ...@@ -286,6 +292,29 @@ public class RelaxedDataBinder extends DataBinder {
this.nodes = splitPath(path); this.nodes = splitPath(path);
} }
private List<PathNode> splitPath(String path) {
List<PathNode> nodes = new ArrayList<PathNode>();
for (String name : StringUtils.delimitedListToStringArray(path, ".")) {
for (String sub : StringUtils.delimitedListToStringArray(name, "[")) {
if (StringUtils.hasText(sub)) {
if (sub.endsWith("]")) {
sub = sub.substring(0, sub.length() - 1);
if (sub.matches("[0-9]+")) {
nodes.add(new ArrayIndexNode(sub));
}
else {
nodes.add(new MapIndexNode(sub));
}
}
else {
nodes.add(new PropertyNode(sub));
}
}
}
}
return nodes;
}
public void collapseKeys(int index) { public void collapseKeys(int index) {
List<PathNode> revised = new ArrayList<PathNode>(); List<PathNode> revised = new ArrayList<PathNode>();
for (int i = 0; i < index; i++) { for (int i = 0; i < index; i++) {
...@@ -401,29 +430,6 @@ public class RelaxedDataBinder extends DataBinder { ...@@ -401,29 +430,6 @@ public class RelaxedDataBinder extends DataBinder {
} }
} }
private List<PathNode> splitPath(String path) {
List<PathNode> nodes = new ArrayList<PathNode>();
for (String name : StringUtils.delimitedListToStringArray(path, ".")) {
for (String sub : StringUtils.delimitedListToStringArray(name, "[")) {
if (StringUtils.hasText(sub)) {
if (sub.endsWith("]")) {
sub = sub.substring(0, sub.length() - 1);
if (sub.matches("[0-9]+")) {
nodes.add(new ArrayIndexNode(sub));
}
else {
nodes.add(new MapIndexNode(sub));
}
}
else {
nodes.add(new PropertyNode(sub));
}
}
}
}
return nodes;
}
} }
} }
...@@ -38,7 +38,6 @@ public final class RelaxedNames implements Iterable<String> { ...@@ -38,7 +38,6 @@ public final class RelaxedNames implements Iterable<String> {
/** /**
* Create a new {@link RelaxedNames} instance. * Create a new {@link RelaxedNames} instance.
*
* @param name the source name. For the maximum number of variations specify the name * @param name the source name. For the maximum number of variations specify the name
* using dashed notation (e.g. {@literal my-property-name} * using dashed notation (e.g. {@literal my-property-name}
*/ */
...@@ -68,18 +67,21 @@ public final class RelaxedNames implements Iterable<String> { ...@@ -68,18 +67,21 @@ public final class RelaxedNames implements Iterable<String> {
} }
static enum Variation { static enum Variation {
NONE { NONE {
@Override @Override
public String apply(String value) { public String apply(String value) {
return value; return value;
} }
}, },
LOWERCASE { LOWERCASE {
@Override @Override
public String apply(String value) { public String apply(String value) {
return value.toLowerCase(); return value.toLowerCase();
} }
}, },
UPPERCASE { UPPERCASE {
@Override @Override
public String apply(String value) { public String apply(String value) {
...@@ -91,30 +93,35 @@ public final class RelaxedNames implements Iterable<String> { ...@@ -91,30 +93,35 @@ public final class RelaxedNames implements Iterable<String> {
} }
static enum Manipulation { static enum Manipulation {
NONE { NONE {
@Override @Override
public String apply(String value) { public String apply(String value) {
return value; return value;
} }
}, },
HYPHEN_TO_UNDERSCORE { HYPHEN_TO_UNDERSCORE {
@Override @Override
public String apply(String value) { public String apply(String value) {
return value.replace("-", "_"); return value.replace("-", "_");
} }
}, },
UNDERSCORE_TO_PERIOD { UNDERSCORE_TO_PERIOD {
@Override @Override
public String apply(String value) { public String apply(String value) {
return value.replace("_", "."); return value.replace("_", ".");
} }
}, },
PERIOD_TO_UNDERSCORE { PERIOD_TO_UNDERSCORE {
@Override @Override
public String apply(String value) { public String apply(String value) {
return value.replace(".", "_"); return value.replace(".", "_");
} }
}, },
CAMELCASE_TO_UNDERSCORE { CAMELCASE_TO_UNDERSCORE {
@Override @Override
public String apply(String value) { public String apply(String value) {
...@@ -131,6 +138,7 @@ public final class RelaxedNames implements Iterable<String> { ...@@ -131,6 +138,7 @@ public final class RelaxedNames implements Iterable<String> {
return builder.toString(); return builder.toString();
} }
}, },
SEPARATED_TO_CAMELCASE { SEPARATED_TO_CAMELCASE {
@Override @Override
public String apply(String value) { public String apply(String value) {
......
...@@ -135,7 +135,7 @@ public class YamlConfigurationFactory<T> implements FactoryBean<T>, MessageSourc ...@@ -135,7 +135,7 @@ public class YamlConfigurationFactory<T> implements FactoryBean<T>, MessageSourc
if (this.logger.isTraceEnabled()) { if (this.logger.isTraceEnabled()) {
this.logger.trace("Yaml document is\n" + this.yaml); this.logger.trace("Yaml document is\n" + this.yaml);
} }
Constructor constructor = new CustomPropertyConstructor(this.type, Constructor constructor = new YamlJavaBeanPropertyConstructor(this.type,
this.propertyAliases); this.propertyAliases);
this.configuration = (T) (new Yaml(constructor)).load(this.yaml); this.configuration = (T) (new Yaml(constructor)).load(this.yaml);
if (this.validator != null) { if (this.validator != null) {
......
...@@ -31,22 +31,21 @@ import org.yaml.snakeyaml.nodes.NodeId; ...@@ -31,22 +31,21 @@ import org.yaml.snakeyaml.nodes.NodeId;
* *
* @author Luke Taylor * @author Luke Taylor
*/ */
public class CustomPropertyConstructor extends Constructor { public class YamlJavaBeanPropertyConstructor extends Constructor {
private final Map<Class<?>, Map<String, Property>> properties = new HashMap<Class<?>, Map<String, Property>>(); private final Map<Class<?>, Map<String, Property>> properties = new HashMap<Class<?>, Map<String, Property>>();
private final PropertyUtils propertyUtils = new PropertyUtils(); private final PropertyUtils propertyUtils = new PropertyUtils();
public CustomPropertyConstructor(Class<?> theRoot) { public YamlJavaBeanPropertyConstructor(Class<?> theRoot) {
super(theRoot); super(theRoot);
this.yamlClassConstructors.put(NodeId.mapping, this.yamlClassConstructors.put(NodeId.mapping,
new CustomPropertyConstructMapping()); new CustomPropertyConstructMapping());
} }
public CustomPropertyConstructor(Class<?> theRoot, public YamlJavaBeanPropertyConstructor(Class<?> theRoot,
Map<Class<?>, Map<String, String>> propertyAliases) { Map<Class<?>, Map<String, String>> propertyAliases) {
this(theRoot); this(theRoot);
for (Class<?> key : propertyAliases.keySet()) { for (Class<?> key : propertyAliases.keySet()) {
Map<String, String> map = propertyAliases.get(key); Map<String, String> map = propertyAliases.get(key);
if (map != null) { if (map != null) {
...@@ -85,7 +84,7 @@ public class CustomPropertyConstructor extends Constructor { ...@@ -85,7 +84,7 @@ public class CustomPropertyConstructor extends Constructor {
@Override @Override
protected Property getProperty(Class<?> type, String name) protected Property getProperty(Class<?> type, String name)
throws IntrospectionException { throws IntrospectionException {
Map<String, Property> forType = CustomPropertyConstructor.this.properties Map<String, Property> forType = YamlJavaBeanPropertyConstructor.this.properties
.get(type); .get(type);
Property property = (forType == null ? null : forType.get(name)); Property property = (forType == null ? null : forType.get(name));
return (property == null ? super.getProperty(type, name) : property); return (property == null ? super.getProperty(type, name) : property);
......
...@@ -30,7 +30,7 @@ public interface PropertySourceLoader { ...@@ -30,7 +30,7 @@ public interface PropertySourceLoader {
* Returns {@code true} if the {@link Resource} is supported. * Returns {@code true} if the {@link Resource} is supported.
* @return if the resource is supported * @return if the resource is supported
*/ */
public boolean supports(Resource resource); boolean supports(Resource resource);
/** /**
* Load the resource into a property source. * Load the resource into a property source.
......
...@@ -57,8 +57,8 @@ public class FileEncodingApplicationListener implements ...@@ -57,8 +57,8 @@ public class FileEncodingApplicationListener implements
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
event.getEnvironment(), "spring."); event.getEnvironment(), "spring.");
if (resolver.containsProperty("mandatoryFileEncoding")) { if (resolver.containsProperty("mandatoryFileEncoding")) {
final String encoding = System.getProperty("file.encoding"); String encoding = System.getProperty("file.encoding");
final String desired = resolver.getProperty("mandatoryFileEncoding"); String desired = resolver.getProperty("mandatoryFileEncoding");
if (encoding != null && !desired.equalsIgnoreCase(encoding)) { if (encoding != null && !desired.equalsIgnoreCase(encoding)) {
logger.error("System property 'file.encoding' is currently '" + encoding logger.error("System property 'file.encoding' is currently '" + encoding
+ "'. It should be '" + desired + "'. It should be '" + desired
...@@ -70,9 +70,8 @@ public class FileEncodingApplicationListener implements ...@@ -70,9 +70,8 @@ public class FileEncodingApplicationListener implements
+ "'. You could use a locale setting that matches encoding='" + "'. You could use a locale setting that matches encoding='"
+ desired + "'."); + desired + "'.");
throw new IllegalStateException( throw new IllegalStateException(
"The Java Virtual Machine has not " "The Java Virtual Machine has not been configured to use the "
+ " been configured to use the desired default character encoding (" + "desired default character encoding (" + desired + ").");
+ desired + ").");
} }
} }
} }
......
...@@ -36,7 +36,6 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon ...@@ -36,7 +36,6 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon
* JSR-330 compliant classes using {@code javax.inject} annotations. Allows for * JSR-330 compliant classes using {@code javax.inject} annotations. Allows for
* registering classes one by one (specifying class names as config location) as well as * registering classes one by one (specifying class names as config location) as well as
* for classpath scanning (specifying base packages as config location). * for classpath scanning (specifying base packages as config location).
*
* <p> * <p>
* Note: In case of multiple {@code @Configuration} classes, later {@code @Bean} * Note: In case of multiple {@code @Configuration} classes, later {@code @Bean}
* definitions will override ones defined in earlier loaded files. This can be leveraged * definitions will override ones defined in earlier loaded files. This can be leveraged
......
...@@ -19,7 +19,6 @@ package org.springframework.boot.context.embedded; ...@@ -19,7 +19,6 @@ package org.springframework.boot.context.embedded;
/** /**
* Simple interface that represents a fully configured embedded servlet container (for * Simple interface that represents a fully configured embedded servlet container (for
* example Tomcat or Jetty). Allows the container to be {@link #stop() stopped}. * example Tomcat or Jetty). Allows the container to be {@link #stop() stopped}.
*
* <p> * <p>
* Instances of this class are usually obtained via a * Instances of this class are usually obtained via a
* {@link EmbeddedServletContainerFactory}. * {@link EmbeddedServletContainerFactory}.
......
...@@ -22,7 +22,6 @@ import org.springframework.beans.factory.config.BeanPostProcessor; ...@@ -22,7 +22,6 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
* Strategy interface for customizing auto-configured embedded servlet containers. Any * Strategy interface for customizing auto-configured embedded servlet containers. Any
* beans of this type will get a callback with the container factory before the container * beans of this type will get a callback with the container factory before the container
* itself is started, so you can set the port, address, error pages etc. * itself is started, so you can set the port, address, error pages etc.
*
* <p> * <p>
* Beware: calls to this interface are usually made from a * Beware: calls to this interface are usually made from a
* {@link EmbeddedServletContainerCustomizerBeanPostProcessor} which is a * {@link EmbeddedServletContainerCustomizerBeanPostProcessor} which is a
......
...@@ -63,4 +63,5 @@ public class EmbeddedServletContainerInitializedEvent extends ApplicationEvent { ...@@ -63,4 +63,5 @@ public class EmbeddedServletContainerInitializedEvent extends ApplicationEvent {
public ApplicationContext getApplicationContext() { public ApplicationContext getApplicationContext() {
return this.applicationContext; return this.applicationContext;
} }
} }
...@@ -56,14 +56,12 @@ import org.springframework.web.context.support.WebApplicationContextUtils; ...@@ -56,14 +56,12 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
/** /**
* A {@link WebApplicationContext} that can be used to bootstrap itself from a contained * A {@link WebApplicationContext} that can be used to bootstrap itself from a contained
* {@link EmbeddedServletContainerFactory} bean. * {@link EmbeddedServletContainerFactory} bean.
*
* <p> * <p>
* This context will create, initialize and run an {@link EmbeddedServletContainer} by * This context will create, initialize and run an {@link EmbeddedServletContainer} by
* searching for a single {@link EmbeddedServletContainerFactory} bean within the * searching for a single {@link EmbeddedServletContainerFactory} bean within the
* {@link ApplicationContext} itself. The {@link EmbeddedServletContainerFactory} is free * {@link ApplicationContext} itself. The {@link EmbeddedServletContainerFactory} is free
* to use standard Spring concepts (such as dependency injection, lifecycle callbacks and * to use standard Spring concepts (such as dependency injection, lifecycle callbacks and
* property placeholder variables). * property placeholder variables).
*
* <p> * <p>
* In addition, any {@link Servlet} or {@link Filter} beans defined in the context will be * In addition, any {@link Servlet} or {@link Filter} beans defined in the context will be
* automatically registered with the embedded Servlet container. In the case of a single * automatically registered with the embedded Servlet container. In the case of a single
...@@ -71,14 +69,12 @@ import org.springframework.web.context.support.WebApplicationContextUtils; ...@@ -71,14 +69,12 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
* the lowercase bean name will be used as a mapping prefix. Any Servlet named * the lowercase bean name will be used as a mapping prefix. Any Servlet named
* 'dispatcherServlet' will always be mapped to '/'. Filter beans will be mapped to all * 'dispatcherServlet' will always be mapped to '/'. Filter beans will be mapped to all
* URLs ('/*'). * URLs ('/*').
*
* <p> * <p>
* For more advanced configuration, the context can instead define beans that implement * For more advanced configuration, the context can instead define beans that implement
* the {@link ServletContextInitializer} interface (most often * the {@link ServletContextInitializer} interface (most often
* {@link ServletRegistrationBean}s and/or {@link FilterRegistrationBean}s). To prevent * {@link ServletRegistrationBean}s and/or {@link FilterRegistrationBean}s). To prevent
* double registration, the use of {@link ServletContextInitializer} beans will disable * double registration, the use of {@link ServletContextInitializer} beans will disable
* automatic Servlet and Filter bean registration. * automatic Servlet and Filter bean registration.
*
* <p> * <p>
* Although this context can be used directly, most developers should consider using the * Although this context can be used directly, most developers should consider using the
* {@link AnnotationConfigEmbeddedWebApplicationContext} or * {@link AnnotationConfigEmbeddedWebApplicationContext} or
......
...@@ -34,7 +34,6 @@ import org.springframework.util.Assert; ...@@ -34,7 +34,6 @@ import org.springframework.util.Assert;
* A {@link ServletContextInitializer} to register {@link Filter}s in a Servlet 3.0+ * A {@link ServletContextInitializer} to register {@link Filter}s in a Servlet 3.0+
* container. Similar to the {@link ServletContext#addFilter(String, Filter) registration} * container. Similar to the {@link ServletContext#addFilter(String, Filter) registration}
* features provided by {@link ServletContext} but with a Spring Bean friendly design. * features provided by {@link ServletContext} but with a Spring Bean friendly design.
*
* <p> * <p>
* The {@link #setFilter(Filter) Filter} must be specified before calling * The {@link #setFilter(Filter) Filter} must be specified before calling
* {@link #onStartup(ServletContext)}. Registrations can be associated with * {@link #onStartup(ServletContext)}. Registrations can be associated with
...@@ -263,4 +262,5 @@ public class FilterRegistrationBean extends RegistrationBean { ...@@ -263,4 +262,5 @@ public class FilterRegistrationBean extends RegistrationBean {
} }
} }
} }
} }
...@@ -112,4 +112,5 @@ public abstract class RegistrationBean implements ServletContextInitializer { ...@@ -112,4 +112,5 @@ public abstract class RegistrationBean implements ServletContextInitializer {
registration.setInitParameters(this.initParameters); registration.setInitParameters(this.initParameters);
} }
} }
} }
...@@ -28,11 +28,9 @@ import org.springframework.web.WebApplicationInitializer; ...@@ -28,11 +28,9 @@ import org.springframework.web.WebApplicationInitializer;
* interface (and do not implement {@link WebApplicationInitializer}) will <b>not</b> be * interface (and do not implement {@link WebApplicationInitializer}) will <b>not</b> be
* detected by {@link SpringServletContainerInitializer} and hence will not be * detected by {@link SpringServletContainerInitializer} and hence will not be
* automatically bootstrapped by the Servlet container. * automatically bootstrapped by the Servlet container.
*
* <p> * <p>
* This interface is primarily designed to allow {@link ServletContextInitializer}s to be * This interface is primarily designed to allow {@link ServletContextInitializer}s to be
* managed by Spring and not the Servlet container. * managed by Spring and not the Servlet container.
*
* <p> * <p>
* For configuration examples see {@link WebApplicationInitializer}. * For configuration examples see {@link WebApplicationInitializer}.
* *
......
...@@ -34,7 +34,6 @@ import org.springframework.util.Assert; ...@@ -34,7 +34,6 @@ import org.springframework.util.Assert;
* container. Similar to the {@link ServletContext#addServlet(String, Servlet) * container. Similar to the {@link ServletContext#addServlet(String, Servlet)
* registration} features provided by {@link ServletContext} but with a Spring Bean * registration} features provided by {@link ServletContext} but with a Spring Bean
* friendly design. * friendly design.
*
* <p> * <p>
* The {@link #setServlet(Servlet) servlet} must be specified before calling * The {@link #setServlet(Servlet) servlet} must be specified before calling
* {@link #onStartup}. URL mapping can be configured used {@link #setUrlMappings} or * {@link #onStartup}. URL mapping can be configured used {@link #setUrlMappings} or
...@@ -173,4 +172,5 @@ public class ServletRegistrationBean extends RegistrationBean { ...@@ -173,4 +172,5 @@ public class ServletRegistrationBean extends RegistrationBean {
registration.setMultipartConfig(this.multipartConfig); registration.setMultipartConfig(this.multipartConfig);
} }
} }
} }
...@@ -53,4 +53,5 @@ public class WebApplicationContextServletContextAwareProcessor extends ...@@ -53,4 +53,5 @@ public class WebApplicationContextServletContextAwareProcessor extends
ServletConfig servletConfig = this.webApplicationContext.getServletConfig(); ServletConfig servletConfig = this.webApplicationContext.getServletConfig();
return (servletConfig != null ? servletConfig : super.getServletConfig()); return (servletConfig != null ? servletConfig : super.getServletConfig());
} }
} }
...@@ -25,7 +25,6 @@ import org.springframework.web.context.support.XmlWebApplicationContext; ...@@ -25,7 +25,6 @@ import org.springframework.web.context.support.XmlWebApplicationContext;
/** /**
* {@link EmbeddedWebApplicationContext} which takes its configuration from XML documents, * {@link EmbeddedWebApplicationContext} which takes its configuration from XML documents,
* understood by an {@link org.springframework.beans.factory.xml.XmlBeanDefinitionReader}. * understood by an {@link org.springframework.beans.factory.xml.XmlBeanDefinitionReader}.
*
* <p> * <p>
* Note: In case of multiple config locations, later bean definitions will override ones * Note: In case of multiple config locations, later bean definitions will override ones
* defined in earlier loaded files. This can be leveraged to deliberately override certain * defined in earlier loaded files. This can be leveraged to deliberately override certain
......
...@@ -40,6 +40,7 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer { ...@@ -40,6 +40,7 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
private final Log logger = LogFactory.getLog(JettyEmbeddedServletContainer.class); private final Log logger = LogFactory.getLog(JettyEmbeddedServletContainer.class);
private final Server server; private final Server server;
private final boolean autoStart; private final boolean autoStart;
/** /**
...@@ -144,4 +145,5 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer { ...@@ -144,4 +145,5 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
public Server getServer() { public Server getServer() {
return this.server; return this.server;
} }
} }
...@@ -49,7 +49,6 @@ import org.springframework.util.StringUtils; ...@@ -49,7 +49,6 @@ import org.springframework.util.StringUtils;
* {@link EmbeddedServletContainerFactory} that can be used to create * {@link EmbeddedServletContainerFactory} that can be used to create
* {@link JettyEmbeddedServletContainer}s. Can be initialized using Spring's * {@link JettyEmbeddedServletContainer}s. Can be initialized using Spring's
* {@link ServletContextInitializer}s or Jetty {@link Configuration}s. * {@link ServletContextInitializer}s or Jetty {@link Configuration}s.
*
* <p> * <p>
* Unless explicitly configured otherwise this factory will created containers that * Unless explicitly configured otherwise this factory will created containers that
* listens for HTTP requests on port 8080. * listens for HTTP requests on port 8080.
...@@ -302,4 +301,5 @@ public class JettyEmbeddedServletContainerFactory extends ...@@ -302,4 +301,5 @@ public class JettyEmbeddedServletContainerFactory extends
} }
} }
} }
} }
...@@ -59,7 +59,6 @@ import org.springframework.util.StreamUtils; ...@@ -59,7 +59,6 @@ import org.springframework.util.StreamUtils;
* {@link EmbeddedServletContainerFactory} that can be used to create * {@link EmbeddedServletContainerFactory} that can be used to create
* {@link TomcatEmbeddedServletContainer}s. Can be initialized using Spring's * {@link TomcatEmbeddedServletContainer}s. Can be initialized using Spring's
* {@link ServletContextInitializer}s or Tomcat {@link LifecycleListener}s. * {@link ServletContextInitializer}s or Tomcat {@link LifecycleListener}s.
*
* <p> * <p>
* Unless explicitly configured otherwise this factory will created containers that * Unless explicitly configured otherwise this factory will created containers that
* listens for HTTP requests on port 8080. * listens for HTTP requests on port 8080.
......
...@@ -122,4 +122,5 @@ public class EnvironmentDelegateApplicationContextInitializer implements ...@@ -122,4 +122,5 @@ public class EnvironmentDelegateApplicationContextInitializer implements
public int getOrder() { public int getOrder() {
return this.order; return this.order;
} }
} }
...@@ -102,4 +102,5 @@ public class EnvironmentDelegateApplicationListener implements ...@@ -102,4 +102,5 @@ public class EnvironmentDelegateApplicationListener implements
public int getOrder() { public int getOrder() {
return this.order; return this.order;
} }
} }
...@@ -35,7 +35,8 @@ public class ServletContextApplicationContextInitializer implements ...@@ -35,7 +35,8 @@ public class ServletContextApplicationContextInitializer implements
private final ServletContext servletContext; private final ServletContext servletContext;
/** /**
* @param servletContext * Create a new {@link ServletContextApplicationContextInitializer} instance
* @param servletContext the servlet that should be ultimately set.
*/ */
public ServletContextApplicationContextInitializer(ServletContext servletContext) { public ServletContextApplicationContextInitializer(ServletContext servletContext) {
this.servletContext = servletContext; this.servletContext = servletContext;
......
...@@ -42,4 +42,5 @@ public abstract class JsonParserFactory { ...@@ -42,4 +42,5 @@ public abstract class JsonParserFactory {
} }
return new SimpleJsonParser(); return new SimpleJsonParser();
} }
} }
...@@ -79,8 +79,7 @@ public final class ClasspathLoggingApplicationListener implements ...@@ -79,8 +79,7 @@ public final class ClasspathLoggingApplicationListener implements
if (classLoader instanceof URLClassLoader) { if (classLoader instanceof URLClassLoader) {
return Arrays.toString(((URLClassLoader) classLoader).getURLs()); return Arrays.toString(((URLClassLoader) classLoader).getURLs());
} }
else {
return "unknown"; return "unknown";
} }
}
} }
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
package org.springframework.boot.logging; package org.springframework.boot.logging;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -46,7 +44,6 @@ import org.springframework.util.ResourceUtils; ...@@ -46,7 +44,6 @@ import org.springframework.util.ResourceUtils;
* system, otherwise a default location is used. The classpath is probed for log4j and * system, otherwise a default location is used. The classpath is probed for log4j and
* logback and if those are present they will be reconfigured, otherwise vanilla * logback and if those are present they will be reconfigured, otherwise vanilla
* <code>java.util.logging</code> will be used. </p> * <code>java.util.logging</code> will be used. </p>
*
* <p> * <p>
* The default config locations are <code>classpath:log4j.properties</code> or * The default config locations are <code>classpath:log4j.properties</code> or
* <code>classpath:log4j.xml</code> for log4j; <code>classpath:logback.xml</code> for * <code>classpath:log4j.xml</code> for log4j; <code>classpath:logback.xml</code> for
...@@ -54,8 +51,6 @@ import org.springframework.util.ResourceUtils; ...@@ -54,8 +51,6 @@ import org.springframework.util.ResourceUtils;
* <code>java.util.logging</code>. If the correct one of those files is not found then * <code>java.util.logging</code>. If the correct one of those files is not found then
* some sensible defaults are adopted from files of the same name but in the package * some sensible defaults are adopted from files of the same name but in the package
* containing {@link LoggingApplicationListener}. * containing {@link LoggingApplicationListener}.
* </p>
*
* <p> * <p>
* Some system properties may be set as side effects, and these can be useful if the * Some system properties may be set as side effects, and these can be useful if the
* logging configuration supports placeholders (i.e. log4j or logback): * logging configuration supports placeholders (i.e. log4j or logback):
...@@ -91,10 +86,8 @@ public class LoggingApplicationListener implements SmartApplicationListener { ...@@ -91,10 +86,8 @@ public class LoggingApplicationListener implements SmartApplicationListener {
LOG_LEVEL_LOGGERS.add(LogLevel.TRACE, "org.hibernate.tool.hbm2ddl"); LOG_LEVEL_LOGGERS.add(LogLevel.TRACE, "org.hibernate.tool.hbm2ddl");
} }
@SuppressWarnings("unchecked") private static Class<?>[] EVENT_TYPES = { ApplicationStartedEvent.class,
private static Collection<Class<? extends ApplicationEvent>> EVENT_TYPES = Arrays ApplicationEnvironmentPreparedEvent.class };
.<Class<? extends ApplicationEvent>> asList(ApplicationStartedEvent.class,
ApplicationEnvironmentPreparedEvent.class);
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());
...@@ -106,7 +99,7 @@ public class LoggingApplicationListener implements SmartApplicationListener { ...@@ -106,7 +99,7 @@ public class LoggingApplicationListener implements SmartApplicationListener {
@Override @Override
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
for (Class<? extends ApplicationEvent> type : EVENT_TYPES) { for (Class<?> type : EVENT_TYPES) {
if (type.isAssignableFrom(eventType)) { if (type.isAssignableFrom(eventType)) {
return true; return true;
} }
...@@ -230,4 +223,5 @@ public class LoggingApplicationListener implements SmartApplicationListener { ...@@ -230,4 +223,5 @@ public class LoggingApplicationListener implements SmartApplicationListener {
public void setParseArgs(boolean parseArgs) { public void setParseArgs(boolean parseArgs) {
this.parseArgs = parseArgs; this.parseArgs = parseArgs;
} }
} }
...@@ -74,4 +74,5 @@ public class JavaLoggingSystem extends AbstractLoggingSystem { ...@@ -74,4 +74,5 @@ public class JavaLoggingSystem extends AbstractLoggingSystem {
Logger logger = Logger.getLogger(loggerName == null ? "" : loggerName); Logger logger = Logger.getLogger(loggerName == null ? "" : loggerName);
logger.setLevel(LEVELS.get(level)); logger.setLevel(LEVELS.get(level));
} }
} }
...@@ -71,4 +71,5 @@ public class ColorConverter extends CompositeConverter<ILoggingEvent> { ...@@ -71,4 +71,5 @@ public class ColorConverter extends CompositeConverter<ILoggingEvent> {
protected String toAnsiString(String in, AnsiElement element) { protected String toAnsiString(String in, AnsiElement element) {
return AnsiOutput.toString(element, in); return AnsiOutput.toString(element, in);
} }
} }
...@@ -22,8 +22,8 @@ import java.util.LinkedHashSet; ...@@ -22,8 +22,8 @@ import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
...@@ -53,7 +53,7 @@ class EntityScanRegistrar implements ImportBeanDefinitionRegistrar { ...@@ -53,7 +53,7 @@ class EntityScanRegistrar implements ImportBeanDefinitionRegistrar {
beanDefinition.setBeanClass(EntityScanBeanPostProcessor.class); beanDefinition.setBeanClass(EntityScanBeanPostProcessor.class);
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue( beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(
getPackagesToScan(importingClassMetadata)); getPackagesToScan(importingClassMetadata));
beanDefinition.setRole(AbstractBeanDefinition.ROLE_INFRASTRUCTURE); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
registry.registerBeanDefinition(BEAN_NAME, beanDefinition); registry.registerBeanDefinition(BEAN_NAME, beanDefinition);
} }
} }
...@@ -122,5 +122,7 @@ class EntityScanRegistrar implements ImportBeanDefinitionRegistrar { ...@@ -122,5 +122,7 @@ class EntityScanRegistrar implements ImportBeanDefinitionRegistrar {
+ "LocalContainerEntityManagerFactoryBean from @EntityScan, " + "LocalContainerEntityManagerFactoryBean from @EntityScan, "
+ "ensure an appropriate bean is registered."); + "ensure an appropriate bean is registered.");
} }
} }
} }
...@@ -28,7 +28,7 @@ import org.springframework.boot.ansi.AnsiOutput; ...@@ -28,7 +28,7 @@ import org.springframework.boot.ansi.AnsiOutput;
import org.springframework.boot.ansi.AnsiOutput.Enabled; import org.springframework.boot.ansi.AnsiOutput.Enabled;
/** /**
* Capture output from System.out and System.err. * JUnit {@code @Rule} to capture output from System.out and System.err.
* *
* @author Phillip Webb * @author Phillip Webb
*/ */
...@@ -126,6 +126,7 @@ public class OutputCapture implements TestRule { ...@@ -126,6 +126,7 @@ public class OutputCapture implements TestRule {
this.copy.flush(); this.copy.flush();
this.original.flush(); this.original.flush();
} }
} }
/** /**
...@@ -148,6 +149,7 @@ public class OutputCapture implements TestRule { ...@@ -148,6 +149,7 @@ public class OutputCapture implements TestRule {
return new AnsiOutputControl(); return new AnsiOutputControl();
} }
} }
} }
private static class AnsiPresentOutputControl extends AnsiOutputControl { private static class AnsiPresentOutputControl extends AnsiOutputControl {
......
...@@ -36,8 +36,7 @@ import org.springframework.web.context.WebApplicationContext; ...@@ -36,8 +36,7 @@ import org.springframework.web.context.WebApplicationContext;
* one Spring servlet, and no more than a single filter (which itself is only enabled when * one Spring servlet, and no more than a single filter (which itself is only enabled when
* Spring Security is detected). If your application is more complicated consider using * Spring Security is detected). If your application is more complicated consider using
* one of the other WebApplicationInitializers. * one of the other WebApplicationInitializers.
* * <p>
* <p/>
* Note that a WebApplicationInitializer is only needed if you are building a war file and * Note that a WebApplicationInitializer is only needed if you are building a war file and
* deploying it. If you prefer to run an embedded container (we do) then you won't need * deploying it. If you prefer to run an embedded container (we do) then you won't need
* this at all. * this at all.
...@@ -95,7 +94,6 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit ...@@ -95,7 +94,6 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
* config classes) because other settings have sensible defaults. You might choose * config classes) because other settings have sensible defaults. You might choose
* (for instance) to add default command line arguments, or set an active Spring * (for instance) to add default command line arguments, or set an active Spring
* profile. * profile.
*
* @param application a builder for the application context * @param application a builder for the application context
* @see SpringApplicationBuilder * @see SpringApplicationBuilder
*/ */
......
...@@ -58,4 +58,5 @@ public class ArrayDocumentMatcher implements DocumentMatcher { ...@@ -58,4 +58,5 @@ public class ArrayDocumentMatcher implements DocumentMatcher {
} }
return MatchStatus.NOT_FOUND; return MatchStatus.NOT_FOUND;
} }
} }
...@@ -38,4 +38,5 @@ public class DefaultProfileDocumentMatcher implements DocumentMatcher { ...@@ -38,4 +38,5 @@ public class DefaultProfileDocumentMatcher implements DocumentMatcher {
return MatchStatus.NOT_FOUND; return MatchStatus.NOT_FOUND;
} }
} }
} }
...@@ -105,4 +105,5 @@ public class YamlPropertiesFactoryBean extends YamlProcessor implements ...@@ -105,4 +105,5 @@ public class YamlPropertiesFactoryBean extends YamlProcessor implements
public boolean isSingleton() { public boolean isSingleton() {
return this.singleton; return this.singleton;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment