1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -70,7 +70,8 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
70
70
* <ul>
71
71
* <li>Calls {@link #validateMergedContextConfiguration(MergedContextConfiguration)}
72
72
* 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>
74
75
* <li>If the supplied {@code MergedContextConfiguration} references a
75
76
* {@linkplain MergedContextConfiguration#getParent() parent configuration},
76
77
* the corresponding {@link MergedContextConfiguration#getParentApplicationContext()
@@ -130,15 +131,6 @@ public final ConfigurableApplicationContext loadContext(MergedContextConfigurati
130
131
return context ;
131
132
}
132
133
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
-
142
134
/**
143
135
* Validate the supplied {@link MergedContextConfiguration} with respect to
144
136
* what this context loader supports.
@@ -159,7 +151,8 @@ protected void validateMergedContextConfiguration(MergedContextConfiguration mer
159
151
* <p>Implementation details:
160
152
*
161
153
* <ul>
162
- * <li>Creates a {@link GenericApplicationContext} instance.</li>
154
+ * <li>Calls {@link #createContext()} to create a {@link GenericApplicationContext}
155
+ * instance.</li>
163
156
* <li>Calls {@link #prepareContext(GenericApplicationContext)} to allow for customizing the context
164
157
* before bean definitions are loaded.</li>
165
158
* <li>Calls {@link #customizeBeanFactory(DefaultListableBeanFactory)} to allow for customizing the
@@ -204,6 +197,22 @@ public final ConfigurableApplicationContext loadContext(String... locations) thr
204
197
return context ;
205
198
}
206
199
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
+ * — 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
+
207
216
/**
208
217
* Prepare the {@link GenericApplicationContext} created by this {@code ContextLoader}.
209
218
* Called <i>before</i> bean definitions are read.
0 commit comments