This commit is contained in:
Andy Wilkinson 2018-05-02 12:09:50 +01:00
parent 31c6281e96
commit 06cf698387
6 changed files with 32 additions and 26 deletions

View File

@ -167,7 +167,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
&& !requiresEagerInit(beanDefinition.getFactoryBeanName())) {
if (this.beanFactory.isFactoryBean(factoryName)) {
Class<?> factoryBeanGeneric = getFactoryBeanGeneric(this.beanFactory,
beanDefinition, name);
beanDefinition);
this.beanTypes.put(name, factoryBeanGeneric);
this.beanTypes.put(factoryName,
this.beanFactory.getType(factoryName));
@ -216,13 +216,12 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
* generics in its method signature.
* @param beanFactory the source bean factory
* @param definition the bean definition
* @param name the name of the bean
* @return the generic type of the {@link FactoryBean} or {@code null}
*/
private Class<?> getFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
BeanDefinition definition, String name) {
BeanDefinition definition) {
try {
return doGetFactoryBeanGeneric(beanFactory, definition, name);
return doGetFactoryBeanGeneric(beanFactory, definition);
}
catch (Exception ex) {
return null;
@ -230,21 +229,21 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
}
private Class<?> doGetFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
BeanDefinition definition, String name)
BeanDefinition definition)
throws Exception, ClassNotFoundException, LinkageError {
if (StringUtils.hasLength(definition.getFactoryBeanName())
&& StringUtils.hasLength(definition.getFactoryMethodName())) {
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition, name);
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition);
}
if (StringUtils.hasLength(definition.getBeanClassName())) {
return getDirectFactoryBeanGeneric(beanFactory, definition, name);
return getDirectFactoryBeanGeneric(beanFactory, definition);
}
return null;
}
private Class<?> getConfigurationClassFactoryBeanGeneric(
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
String name) throws Exception {
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
throws Exception {
Method method = getFactoryMethod(beanFactory, definition);
Class<?> generic = ResolvableType.forMethodReturnType(method)
.as(FactoryBean.class).resolveGeneric();
@ -305,8 +304,8 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
}
private Class<?> getDirectFactoryBeanGeneric(
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
String name) throws ClassNotFoundException, LinkageError {
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
throws ClassNotFoundException, LinkageError {
Class<?> factoryBeanClass = ClassUtils.forName(definition.getBeanClassName(),
beanFactory.getBeanClassLoader());
Class<?> generic = ResolvableType.forClass(factoryBeanClass).as(FactoryBean.class)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import java.io.File;
import java.net.URL;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -62,12 +62,16 @@ public class LocalDevToolsAutoConfiguration {
@ConditionalOnProperty(prefix = "spring.devtools.livereload", name = "enabled", matchIfMissing = true)
static class LiveReloadConfiguration {
@Autowired
private DevToolsProperties properties;
@Autowired(required = false)
private LiveReloadServer liveReloadServer;
LiveReloadConfiguration(DevToolsProperties properties,
ObjectProvider<LiveReloadServer> liveReloadServer) {
this.properties = properties;
this.liveReloadServer = liveReloadServer.getIfAvailable();
}
@Bean
@RestartScope
@ConditionalOnMissingBean
@ -102,8 +106,11 @@ public class LocalDevToolsAutoConfiguration {
@ConditionalOnProperty(prefix = "spring.devtools.restart", name = "enabled", matchIfMissing = true)
static class RestartConfiguration {
@Autowired
private DevToolsProperties properties;
private final DevToolsProperties properties;
RestartConfiguration(DevToolsProperties properties) {
this.properties = properties;
}
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -80,7 +80,7 @@ class Connection {
public void run() throws Exception {
if (this.header.contains("Upgrade: websocket")
&& this.header.contains("Sec-WebSocket-Version: 13")) {
runWebSocket(this.header);
runWebSocket();
}
if (this.header.contains("GET /livereload.js")) {
this.outputStream.writeHttp(getClass().getResourceAsStream("livereload.js"),
@ -88,7 +88,7 @@ class Connection {
}
}
private void runWebSocket(String header) throws Exception {
private void runWebSocket() throws Exception {
String accept = getWebsocketAcceptResponse();
this.outputStream.writeHeaders("HTTP/1.1 101 Switching Protocols",
"Upgrade: websocket", "Connection: Upgrade",

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -60,6 +60,7 @@ public class JsonContentTests {
assertThat(content).isNotNull();
}
@SuppressWarnings("deprecation")
@Test
public void assertThatShouldReturnJsonContentAssert() throws Exception {
JsonContent<ExampleObject> content = new JsonContent<ExampleObject>(getClass(),

View File

@ -208,7 +208,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
addPreviouslyRemovedConnectors();
Connector connector = this.tomcat.getConnector();
if (connector != null && this.autoStart) {
startConnector(connector);
performDeferredLoadOnStartup();
}
checkThatConnectorsHaveStarted();
this.started = true;
@ -281,7 +281,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
}
}
private void startConnector(Connector connector) {
private void performDeferredLoadOnStartup() {
try {
for (Container child : this.tomcat.getHost().findChildren()) {
if (child instanceof TomcatEmbeddedContext) {

View File

@ -127,7 +127,7 @@ public class PropertySourcesLoader {
if (canLoadFileExtension(loader, resource)) {
PropertySource<?> specific = loader.load(sourceName, resource,
profile);
addPropertySource(group, specific, profile);
addPropertySource(group, specific);
return specific;
}
}
@ -154,8 +154,7 @@ public class PropertySourcesLoader {
return false;
}
private void addPropertySource(String basename, PropertySource<?> source,
String profile) {
private void addPropertySource(String basename, PropertySource<?> source) {
if (source == null) {
return;