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
e6d46f57
Commit
e6d46f57
authored
Dec 09, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Defer WebApplicationContext initialization"
This reverts commit
17631486
.
parent
17631486
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
34 deletions
+14
-34
SpringBootServletInitializer.java
...mework/boot/context/web/SpringBootServletInitializer.java
+14
-34
No files found.
spring-boot/src/main/java/org/springframework/boot/context/web/SpringBootServletInitializer.java
View file @
e6d46f57
...
...
@@ -20,7 +20,6 @@ import javax.servlet.Filter;
import
javax.servlet.Servlet
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContextEvent
;
import
javax.servlet.ServletContextListener
;
import
javax.servlet.ServletException
;
import
org.apache.commons.logging.Log
;
...
...
@@ -63,7 +62,20 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
@Override
public
void
onStartup
(
ServletContext
servletContext
)
throws
ServletException
{
servletContext
.
addListener
(
new
Listener
());
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
}
});
}
else
{
this
.
logger
.
debug
(
"No ContextLoaderListener registered, as "
+
"createRootApplicationContext() did not "
+
"return an application context"
);
}
}
protected
WebApplicationContext
createRootApplicationContext
(
...
...
@@ -124,36 +136,4 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
return
application
;
}
/**
* {@link ServletContextListener} used to load the context
*/
private
class
Listener
implements
ServletContextListener
{
private
ContextLoaderListener
contextLoaderListener
;
@Override
public
void
contextInitialized
(
ServletContextEvent
event
)
{
ServletContext
servletContext
=
event
.
getServletContext
();
WebApplicationContext
applicationContext
=
createRootApplicationContext
(
servletContext
);
if
(
applicationContext
==
null
)
{
SpringBootServletInitializer
.
this
.
logger
.
debug
(
"No ContextLoaderListener registered, as "
+
"createRootApplicationContext() did not "
+
"return an application context"
);
}
else
{
this
.
contextLoaderListener
=
new
ContextLoaderListener
(
applicationContext
);
// Don't delegate contextInitialized event as we're already setup
}
}
@Override
public
void
contextDestroyed
(
ServletContextEvent
event
)
{
if
(
this
.
contextLoaderListener
!=
null
)
{
this
.
contextLoaderListener
.
contextDestroyed
(
event
);
}
}
}
}
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