Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
16cab0d8
Commit
16cab0d8
authored
Jun 04, 2020
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x'
Closes gh-21690
parents
87f5894a
4d37430b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
21 deletions
+37
-21
SpringBootServletInitializer.java
...oot/web/servlet/support/SpringBootServletInitializer.java
+37
-21
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java
View file @
16cab0d8
...
...
@@ -92,27 +92,9 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
// Logger initialization is deferred in case an ordered
// LogServletContextInitializer is being used
this
.
logger
=
LogFactory
.
getLog
(
getClass
());
WebApplicationContext
rootAppContext
=
createRootApplicationContext
(
servletContext
);
if
(
rootAppContext
!=
null
)
{
servletContext
.
addListener
(
new
ContextLoaderListener
(
rootAppContext
)
{
@Override
public
void
contextInitialized
(
ServletContextEvent
event
)
{
// no-op because the application context is already initialized
}
@Override
public
void
contextDestroyed
(
ServletContextEvent
event
)
{
try
{
super
.
contextDestroyed
(
event
);
}
finally
{
deregisterJdbcDrivers
(
event
.
getServletContext
());
}
}
});
WebApplicationContext
rootApplicationContext
=
createRootApplicationContext
(
servletContext
);
if
(
rootApplicationContext
!=
null
)
{
servletContext
.
addListener
(
new
SpringBootContextLoaderListener
(
rootApplicationContext
,
servletContext
));
}
else
{
this
.
logger
.
debug
(
"No ContextLoaderListener registered, as createRootApplicationContext() did not "
...
...
@@ -212,6 +194,10 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
return
builder
;
}
/**
* {@link ApplicationListener} to trigger
* {@link ConfigurableWebEnvironment#initPropertySources(ServletContext, javax.servlet.ServletConfig)}.
*/
private
static
final
class
WebEnvironmentPropertySourceInitializer
implements
ApplicationListener
<
ApplicationEnvironmentPreparedEvent
>,
Ordered
{
...
...
@@ -236,4 +222,34 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
}
/**
* {@link ContextLoaderListener} for the initialized context.
*/
private
class
SpringBootContextLoaderListener
extends
ContextLoaderListener
{
private
final
ServletContext
servletContext
;
SpringBootContextLoaderListener
(
WebApplicationContext
applicationContext
,
ServletContext
servletContext
)
{
super
(
applicationContext
);
this
.
servletContext
=
servletContext
;
}
@Override
public
void
contextInitialized
(
ServletContextEvent
event
)
{
// no-op because the application context is already initialized
}
@Override
public
void
contextDestroyed
(
ServletContextEvent
event
)
{
try
{
super
.
contextDestroyed
(
event
);
}
finally
{
// Use original context so that the classloader can be accessed
deregisterJdbcDrivers
(
this
.
servletContext
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment