1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2024 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.
@@ -152,7 +152,7 @@ public class ContextLoader {
152
152
* The root WebApplicationContext instance that this loader manages.
153
153
*/
154
154
@ Nullable
155
- private WebApplicationContext context ;
155
+ private WebApplicationContext rootContext ;
156
156
157
157
/** Actual ApplicationContextInitializer instances to apply to the context. */
158
158
private final List <ApplicationContextInitializer <ConfigurableApplicationContext >> contextInitializers =
@@ -205,12 +205,12 @@ public ContextLoader() {
205
205
* WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE} and subclasses are
206
206
* free to call the {@link #closeWebApplicationContext} method on container shutdown
207
207
* to close the application context.
208
- * @param context the application context to manage
208
+ * @param rootContext the application context to manage
209
209
* @see #initWebApplicationContext(ServletContext)
210
210
* @see #closeWebApplicationContext(ServletContext)
211
211
*/
212
- public ContextLoader (WebApplicationContext context ) {
213
- this .context = context ;
212
+ public ContextLoader (WebApplicationContext rootContext ) {
213
+ this .rootContext = rootContext ;
214
214
}
215
215
216
216
@@ -259,10 +259,10 @@ public WebApplicationContext initWebApplicationContext(ServletContext servletCon
259
259
try {
260
260
// Store context in local instance variable, to guarantee that
261
261
// it is available on ServletContext shutdown.
262
- if (this .context == null ) {
263
- this .context = createWebApplicationContext (servletContext );
262
+ if (this .rootContext == null ) {
263
+ this .rootContext = createWebApplicationContext (servletContext );
264
264
}
265
- if (this .context instanceof ConfigurableWebApplicationContext cwac && !cwac .isActive ()) {
265
+ if (this .rootContext instanceof ConfigurableWebApplicationContext cwac && !cwac .isActive ()) {
266
266
// The context has not yet been refreshed -> provide services such as
267
267
// setting the parent context, setting the application context id, etc
268
268
if (cwac .getParent () == null ) {
@@ -273,22 +273,22 @@ public WebApplicationContext initWebApplicationContext(ServletContext servletCon
273
273
}
274
274
configureAndRefreshWebApplicationContext (cwac , servletContext );
275
275
}
276
- servletContext .setAttribute (WebApplicationContext .ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE , this .context );
276
+ servletContext .setAttribute (WebApplicationContext .ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE , this .rootContext );
277
277
278
278
ClassLoader ccl = Thread .currentThread ().getContextClassLoader ();
279
279
if (ccl == ContextLoader .class .getClassLoader ()) {
280
- currentContext = this .context ;
280
+ currentContext = this .rootContext ;
281
281
}
282
282
else if (ccl != null ) {
283
- currentContextPerThread .put (ccl , this .context );
283
+ currentContextPerThread .put (ccl , this .rootContext );
284
284
}
285
285
286
286
if (logger .isInfoEnabled ()) {
287
287
long elapsedTime = System .currentTimeMillis () - startTime ;
288
288
logger .info ("Root WebApplicationContext initialized in " + elapsedTime + " ms" );
289
289
}
290
290
291
- return this .context ;
291
+ return this .rootContext ;
292
292
}
293
293
catch (RuntimeException | Error ex ) {
294
294
logger .error ("Context initialization failed" , ex );
@@ -506,7 +506,7 @@ protected ApplicationContext loadParentContext(ServletContext servletContext) {
506
506
public void closeWebApplicationContext (ServletContext servletContext ) {
507
507
servletContext .log ("Closing Spring root WebApplicationContext" );
508
508
try {
509
- if (this .context instanceof ConfigurableWebApplicationContext cwac ) {
509
+ if (this .rootContext instanceof ConfigurableWebApplicationContext cwac ) {
510
510
cwac .close ();
511
511
}
512
512
}
0 commit comments