public class JohnsonDispatcherServlet
extends org.springframework.web.servlet.DispatcherServlet
DispatcherServlet to make it Johnson-aware. When using this class, if the root
Spring context fails to start the dispatcher will not attempt to create/start its child context.
The goal of this class is to prevent the web application from being shutdown if SpringMVC cannot be started. By
default, if the dispatcher's 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 |
PREFIX_BYPASSED
The prefix for the attribute added to the
ServletContext when Spring MVC initialization is bypassed
because a previous Event indicates the application has already failed. |
FLASH_MAP_MANAGER_ATTRIBUTE, FLASH_MAP_MANAGER_BEAN_NAME, HANDLER_ADAPTER_BEAN_NAME, HANDLER_EXCEPTION_RESOLVER_BEAN_NAME, HANDLER_MAPPING_BEAN_NAME, INPUT_FLASH_MAP_ATTRIBUTE, LOCALE_RESOLVER_ATTRIBUTE, LOCALE_RESOLVER_BEAN_NAME, MULTIPART_RESOLVER_BEAN_NAME, OUTPUT_FLASH_MAP_ATTRIBUTE, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger, REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME, THEME_RESOLVER_ATTRIBUTE, THEME_RESOLVER_BEAN_NAME, THEME_SOURCE_ATTRIBUTE, VIEW_RESOLVER_BEAN_NAME, WEB_APPLICATION_CONTEXT_ATTRIBUTE| Constructor and Description |
|---|
JohnsonDispatcherServlet() |
JohnsonDispatcherServlet(org.springframework.web.context.WebApplicationContext webApplicationContext) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
void |
destroy()
Performs standard SpringMVC
DispatcherServlet teardown and ensures any attributes added to the servlet
context for this dispatcher are removed. |
protected String |
getBypassedAttributeName()
Allows derived classes to override the name of the attribute which is added to the
ServletContext when
this dispatcher is bypassed (whether due to the JohnsonContextLoaderListener being bypassed or due to
the initialisation of the dispatcher failing). |
protected org.springframework.web.context.WebApplicationContext |
initWebApplicationContext()
Overrides the standard SpringMVC
DispatcherServlet initialisation to make it Johnson-aware, allowing it
to be automatically bypassed, when paired with a JohnsonContextLoaderListener, or add an Event
if initialisation fails. |
buildLocaleContext, checkMultipart, cleanupMultipart, createDefaultStrategy, doDispatch, doService, getDefaultStrategies, getDefaultStrategy, getDefaultViewName, getHandler, getHandler, getHandlerAdapter, getMultipartResolver, getThemeSource, initStrategies, noHandlerFound, onRefresh, processHandlerException, render, resolveViewName, setCleanupAfterInclude, setDetectAllHandlerAdapters, setDetectAllHandlerExceptionResolvers, setDetectAllHandlerMappings, setDetectAllViewResolversapplyInitializers, buildRequestAttributes, configureAndRefreshWebApplicationContext, createWebApplicationContext, createWebApplicationContext, doDelete, doGet, doOptions, doPost, doPut, doTrace, findWebApplicationContext, getContextAttribute, getContextClass, getContextConfigLocation, getContextId, getNamespace, getServletContextAttributeName, getUsernameForRequest, getWebApplicationContext, initFrameworkServlet, initServletBean, onApplicationEvent, postProcessWebApplicationContext, processRequest, refresh, service, setContextAttribute, setContextClass, setContextConfigLocation, setContextId, setContextInitializerClasses, setContextInitializers, setDispatchOptionsRequest, setDispatchTraceRequest, setNamespace, setPublishContext, setPublishEvents, setThreadContextInheritableaddRequiredProperty, createEnvironment, getEnvironment, getServletContext, getServletName, init, initBeanWrapper, setEnvironmentpublic static final String PREFIX_BYPASSED
ServletContext when Spring MVC initialization is bypassed
because a previous Event indicates the application has already failed. The MVC dispatcher's name is
appended to this prefix, separated by a colon, to form the attribute.getBypassedAttributeName()public JohnsonDispatcherServlet()
public JohnsonDispatcherServlet(org.springframework.web.context.WebApplicationContext webApplicationContext)
public void destroy()
DispatcherServlet teardown and ensures any attributes added to the servlet
context for this dispatcher are removed.destroy in interface javax.servlet.Servletdestroy in class org.springframework.web.servlet.FrameworkServletprotected org.springframework.web.context.WebApplicationContext initWebApplicationContext()
DispatcherServlet initialisation to make it Johnson-aware, allowing it
to be automatically bypassed, when paired with a JohnsonContextLoaderListener, 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 the main WebApplicationContext being bypassed
or failing to initialise) or if initialisation fails.
initWebApplicationContext in class org.springframework.web.servlet.FrameworkServletnull 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 WebApplicationContextnull@Nonnull protected String getBypassedAttributeName()
ServletContext when
this dispatcher is bypassed (whether due to the JohnsonContextLoaderListener being bypassed or due to
the initialisation of the dispatcher failing).
The default attribute name is: "PREFIX_BYPASSED:getServletName()"
Copyright © 2017 Atlassian. All rights reserved.