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