Class SpringBootBootstrappingServletContextListener
java.lang.Object
org.broadleafcommerce.common.web.boot.support.SpringBootBootstrappingServletContextListener
- All Implemented Interfaces:
jakarta.servlet.ServletContextListener,EventListener
public class SpringBootBootstrappingServletContextListener
extends Object
implements jakarta.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>
- Author:
- Phillip Verheyden (phillipuniverse)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected org.springframework.web.context.ContextLoaderListener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontextDestroyed(jakarta.servlet.ServletContextEvent event) voidcontextInitialized(jakarta.servlet.ServletContextEvent event) protected org.springframework.web.WebApplicationInitializercreateInitializer(Class<org.springframework.web.WebApplicationInitializer> initializerClass) protected Class<org.springframework.web.WebApplicationInitializer>getInitializerClass(jakarta.servlet.ServletContext ctx)
-
Field Details
-
APPLICATION_CLASS
- See Also:
-
delegateListener
protected org.springframework.web.context.ContextLoaderListener delegateListener
-
-
Constructor Details
-
SpringBootBootstrappingServletContextListener
public SpringBootBootstrappingServletContextListener()
-
-
Method Details
-
contextInitialized
public void contextInitialized(jakarta.servlet.ServletContextEvent event) - Specified by:
contextInitializedin interfacejakarta.servlet.ServletContextListener
-
contextDestroyed
public void contextDestroyed(jakarta.servlet.ServletContextEvent event) - Specified by:
contextDestroyedin interfacejakarta.servlet.ServletContextListener
-
getInitializerClass
protected Class<org.springframework.web.WebApplicationInitializer> getInitializerClass(jakarta.servlet.ServletContext ctx) throws ClassNotFoundException, LinkageError - Throws:
ClassNotFoundExceptionLinkageError
-
createInitializer
protected org.springframework.web.WebApplicationInitializer createInitializer(Class<org.springframework.web.WebApplicationInitializer> initializerClass) throws PrivilegedActionException - Throws:
PrivilegedActionException
-