public class JohnsonContextLoaderListener
extends org.springframework.web.context.ContextLoaderListener
ContextLoaderListener to make it Johnson-aware. When using this class, if the
Spring context fails to start an event will added to Johnson rather than propagated to the servlet container.
The goal of this class is to prevent the web application from being shutdown if Spring cannot be started. By default,
if the WebApplicationContext cannot be started for any reason, an exception is thrown which is propagated up
to the container. When this happens, the entire web application is terminated. This precludes the use of Johnson,
which requires that the web application be up so that it can serve its status pages.
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTR_BYPASSED
The attribute added to the
ServletContext when Spring context initialization is bypassed because a
previous Event indicates the application has already failed. |
| Constructor and Description |
|---|
JohnsonContextLoaderListener() |
JohnsonContextLoaderListener(org.springframework.web.context.WebApplicationContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
contextDestroyed(javax.servlet.ServletContextEvent event)
Performs standard Spring
ContextLoaderListener teardown and ensures any attributes added to the servlet
context for this dispatcher are removed. |
protected Event |
createEvent(String defaultEventType,
String defaultMessage,
Throwable t)
May be overridden in derived classes to allow them to override the default event type or message based on
application-specific understanding of the exception that was thrown.
|
org.springframework.web.context.WebApplicationContext |
initWebApplicationContext(javax.servlet.ServletContext servletContext)
Overrides the standard Spring
ContextLoaderListener initialisation to make it Johnson-aware, allowing it
to be automatically bypassed, when application checks
produce fatal events, or add an Event if initialisation fails. |
contextInitialized, createContextLoader, getContextLoadercloseWebApplicationContext, configureAndRefreshWebApplicationContext, createWebApplicationContext, createWebApplicationContext, customizeContext, determineContextClass, determineContextInitializerClasses, getCurrentWebApplicationContext, loadParentContextpublic JohnsonContextLoaderListener()
public JohnsonContextLoaderListener(org.springframework.web.context.WebApplicationContext context)
public void contextDestroyed(javax.servlet.ServletContextEvent event)
ContextLoaderListener teardown and ensures any attributes added to the servlet
context for this dispatcher are removed.contextDestroyed in interface javax.servlet.ServletContextListenercontextDestroyed in class org.springframework.web.context.ContextLoaderListenerevent - the context eventpublic org.springframework.web.context.WebApplicationContext initWebApplicationContext(javax.servlet.ServletContext servletContext)
ContextLoaderListener initialisation to make it Johnson-aware, allowing it
to be automatically bypassed, when application checks
produce fatal events, or add an Event if initialisation fails.
This implementation will never throw an exception. Unlike the base implementation, though, it may return
null if initialisation is bypassed (due to previous fatal events or failing to initialise) or if
initialisation fails.
initWebApplicationContext in class org.springframework.web.context.ContextLoaderservletContext - the servlet contextnull if initialisation is bypassed or fails@Nonnull protected Event createEvent(@Nonnull String defaultEventType, @Nonnull String defaultMessage, @Nonnull Throwable t)
For cases where derived classes are not able to offer a more specific event type or message, they are encouraged to fall back on the behaviour of this superclass method.
defaultEventType - the default event type to use if no more specific type is appropriatedefaultMessage - the default message to use if no more specific message is availablet - the exception thrown while attempting to initialise the WebApplicationContextnullCopyright © 2017 Atlassian. All rights reserved.