Commit 2f138d84 authored by Dave Syer's avatar Dave Syer

Merge pull request #336 from jkubrynski/master

* pull336:
  Now custom SpringApplication class can be used when extending SpringApplicationContextLoader
parents 76c56c6a 6f2e133a
...@@ -58,7 +58,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader { ...@@ -58,7 +58,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) public ApplicationContext loadContext(MergedContextConfiguration mergedConfig)
throws Exception { throws Exception {
SpringApplication application = new SpringApplication(); SpringApplication application = getSpringApplication();
application.setSources(getSources(mergedConfig)); application.setSources(getSources(mergedConfig));
if (!ObjectUtils.isEmpty(mergedConfig.getActiveProfiles())) { if (!ObjectUtils.isEmpty(mergedConfig.getActiveProfiles())) {
application.setAdditionalProfiles(mergedConfig.getActiveProfiles()); application.setAdditionalProfiles(mergedConfig.getActiveProfiles());
...@@ -77,6 +77,15 @@ public class SpringApplicationContextLoader extends AbstractContextLoader { ...@@ -77,6 +77,15 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
return application.run(); return application.run();
} }
/**
* Builds new {@link org.springframework.boot.SpringApplication} instance. You can override
* this method to add custom behaviour
* @return {@link org.springframework.boot.SpringApplication} instance
*/
protected SpringApplication getSpringApplication() {
return new SpringApplication();
}
private Set<Object> getSources(MergedContextConfiguration mergedConfig) { private Set<Object> getSources(MergedContextConfiguration mergedConfig) {
Set<Object> sources = new LinkedHashSet<Object>(); Set<Object> sources = new LinkedHashSet<Object>();
sources.addAll(Arrays.asList(mergedConfig.getClasses())); sources.addAll(Arrays.asList(mergedConfig.getClasses()));
......
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