public class SpringBootBootstrappingServletContextListener extends Object implements javax.servlet.ServletContextListener
Bootstraps a Spring Boot application using a ServletContextListener rather than the default of using a ServletContextInitializer. The use case here is when you absolutely have to use a web.xml and cannot rely on classpath scanning for a ServletContextInitializer
This is designed to work in conjunction with the BroadleafBootServletContextInitializer (although not requried) which serves
as a drop-in replacement for SpringBootServletInitializer.
Given an application that looks like this:
package com.mycompany
@SpringBootApplication
public class MyApplication extends BroadleafBootServletContextInitializer {
}
A web.xml should contain the following listener configuration:
<context-param>
<param-name>listenerContextInitializerClass</param-name>
<param-value>com.mycompany.MyApplication</param-value>
</context-param>
<listener>
<listener-class>org.broadleafcommerce.common.web.boot.support.SpringBootBootstrappingServletContextListener</listener-class>
</listener>
BroadleafBootServletContextInitializer| Modifier and Type | Field and Description |
|---|---|
static String |
APPLICATION_CLASS |
protected org.springframework.web.context.ContextLoaderListener |
delegateListener |
| Constructor and Description |
|---|
SpringBootBootstrappingServletContextListener() |
| Modifier and Type | Method and Description |
|---|---|
void |
contextDestroyed(javax.servlet.ServletContextEvent event) |
void |
contextInitialized(javax.servlet.ServletContextEvent event) |
protected org.springframework.web.WebApplicationInitializer |
createInitializer(Class<org.springframework.web.WebApplicationInitializer> initializerClass) |
protected Class<org.springframework.web.WebApplicationInitializer> |
getInitializerClass(javax.servlet.ServletContext ctx) |
public static final String APPLICATION_CLASS
protected org.springframework.web.context.ContextLoaderListener delegateListener
public SpringBootBootstrappingServletContextListener()
public void contextInitialized(javax.servlet.ServletContextEvent event)
contextInitialized in interface javax.servlet.ServletContextListenerpublic void contextDestroyed(javax.servlet.ServletContextEvent event)
contextDestroyed in interface javax.servlet.ServletContextListenerprotected Class<org.springframework.web.WebApplicationInitializer> getInitializerClass(javax.servlet.ServletContext ctx) throws ClassNotFoundException, LinkageError
ClassNotFoundExceptionLinkageErrorprotected org.springframework.web.WebApplicationInitializer createInitializer(Class<org.springframework.web.WebApplicationInitializer> initializerClass) throws PrivilegedActionException
PrivilegedActionExceptionCopyright © 2019. All rights reserved.