Limit spring.factories in RemoteSpringApplication

Update RemoteSpringApplication so that initializers and listeners are
prescribed and not loaded from spring.factories.

Fixes gh-3925
pull/4042/head
Phillip Webb 9 years ago
parent 4bdfb1af85
commit 49583c0aa3

@ -16,12 +16,24 @@
package org.springframework.boot.devtools; package org.springframework.boot.devtools;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.boot.Banner; import org.springframework.boot.Banner;
import org.springframework.boot.ResourceBanner; import org.springframework.boot.ResourceBanner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.AnsiOutputApplicationListener;
import org.springframework.boot.context.config.ConfigFileEnvironmentPostProcessor;
import org.springframework.boot.devtools.remote.client.RemoteClientConfiguration; import org.springframework.boot.devtools.remote.client.RemoteClientConfiguration;
import org.springframework.boot.devtools.restart.RestartInitializer; import org.springframework.boot.devtools.restart.RestartInitializer;
import org.springframework.boot.devtools.restart.RestartScopeInitializer;
import org.springframework.boot.devtools.restart.Restarter; import org.springframework.boot.devtools.restart.Restarter;
import org.springframework.boot.env.EnvironmentPostProcessingApplicationListener;
import org.springframework.boot.logging.ClasspathLoggingApplicationListener;
import org.springframework.boot.logging.LoggingApplicationListener;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ApplicationListener;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
/** /**
@ -46,11 +58,29 @@ public final class RemoteSpringApplication {
RemoteClientConfiguration.class); RemoteClientConfiguration.class);
application.setWebEnvironment(false); application.setWebEnvironment(false);
application.setBanner(getBanner()); application.setBanner(getBanner());
application.addListeners(new RemoteUrlPropertyExtractor()); application.setInitializers(getInitializers());
application.setListeners(getListeners());
application.run(args); application.run(args);
waitIndefinitely(); waitIndefinitely();
} }
private Collection<ApplicationContextInitializer<?>> getInitializers() {
List<ApplicationContextInitializer<?>> initializers = new ArrayList<ApplicationContextInitializer<?>>();
initializers.add(new RestartScopeInitializer());
return initializers;
}
private Collection<ApplicationListener<?>> getListeners() {
List<ApplicationListener<?>> listeners = new ArrayList<ApplicationListener<?>>();
listeners.add(new AnsiOutputApplicationListener());
listeners.add(new ConfigFileEnvironmentPostProcessor());
listeners.add(new EnvironmentPostProcessingApplicationListener());
listeners.add(new ClasspathLoggingApplicationListener());
listeners.add(new LoggingApplicationListener());
listeners.add(new RemoteUrlPropertyExtractor());
return listeners;
}
private Banner getBanner() { private Banner getBanner() {
ClassPathResource banner = new ClassPathResource("remote-banner.txt", ClassPathResource banner = new ClassPathResource("remote-banner.txt",
RemoteSpringApplication.class); RemoteSpringApplication.class);

@ -93,7 +93,6 @@ public class RestartServer {
} }
updateTimeStamp(urls); updateTimeStamp(urls);
restart(urls, files); restart(urls, files);
} }
private boolean updateFileSystem(URL url, String name, ClassLoaderFile classLoaderFile) { private boolean updateFileSystem(URL url, String name, ClassLoaderFile classLoaderFile) {

Loading…
Cancel
Save