Skip to content

Commit d939016

Browse files
committed
Polish contribution
See gh-25600
1 parent a83529c commit d939016

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

spring-test/src/main/java/org/springframework/test/context/support/AbstractGenericContextLoader.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -70,7 +70,8 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
7070
* <ul>
7171
* <li>Calls {@link #validateMergedContextConfiguration(MergedContextConfiguration)}
7272
* to allow subclasses to validate the supplied configuration before proceeding.</li>
73-
* <li>Creates a {@link GenericApplicationContext} instance.</li>
73+
* <li>Calls {@link #createContext()} to create a {@link GenericApplicationContext}
74+
* instance.</li>
7475
* <li>If the supplied {@code MergedContextConfiguration} references a
7576
* {@linkplain MergedContextConfiguration#getParent() parent configuration},
7677
* the corresponding {@link MergedContextConfiguration#getParentApplicationContext()
@@ -130,15 +131,6 @@ public final ConfigurableApplicationContext loadContext(MergedContextConfigurati
130131
return context;
131132
}
132133

133-
/**
134-
* Creates instance of application context used by this {@code ContextLoader}
135-
*
136-
* @return new Instance of application context
137-
*/
138-
protected GenericApplicationContext createContext() {
139-
return new GenericApplicationContext();
140-
}
141-
142134
/**
143135
* Validate the supplied {@link MergedContextConfiguration} with respect to
144136
* what this context loader supports.
@@ -159,7 +151,8 @@ protected void validateMergedContextConfiguration(MergedContextConfiguration mer
159151
* <p>Implementation details:
160152
*
161153
* <ul>
162-
* <li>Creates a {@link GenericApplicationContext} instance.</li>
154+
* <li>Calls {@link #createContext()} to create a {@link GenericApplicationContext}
155+
* instance.</li>
163156
* <li>Calls {@link #prepareContext(GenericApplicationContext)} to allow for customizing the context
164157
* before bean definitions are loaded.</li>
165158
* <li>Calls {@link #customizeBeanFactory(DefaultListableBeanFactory)} to allow for customizing the
@@ -204,6 +197,22 @@ public final ConfigurableApplicationContext loadContext(String... locations) thr
204197
return context;
205198
}
206199

200+
/**
201+
* Factory method for creating the {@link GenericApplicationContext} used by
202+
* this {@code ContextLoader}.
203+
*
204+
* <p>The default implementation creates a {@code GenericApplicationContext}
205+
* using the default constructor. This method may be overridden in subclasses
206+
* &mdash; for example, to create a {@code GenericApplicationContext} with
207+
* a custom {@link DefaultListableBeanFactory} implementation.
208+
*
209+
* @return a newly instantiated {@code GenericApplicationContext}
210+
* @since 5.2.9
211+
*/
212+
protected GenericApplicationContext createContext() {
213+
return new GenericApplicationContext();
214+
}
215+
207216
/**
208217
* Prepare the {@link GenericApplicationContext} created by this {@code ContextLoader}.
209218
* Called <i>before</i> bean definitions are read.

0 commit comments

Comments
 (0)