public class SpringEventType extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
PARAM_ADD_EVENT_ON_BYPASS
Defines the
init-param which may be used for controlling whether an event is added when a portion of
Spring initialisation is bypassed due to previous errors. |
static String |
PARAM_EVENT_TYPE
Defines the
init-param which may be used for controlling the event type added when Spring events occur. |
static String |
PARAM_EXCEPTION_TRANSLATOR_CLASS
An
init-param which can be applied to the ServletContext or ServletConfig to register
one or more EventExceptionTranslator types to be applied to exceptions thrown from Spring or SpringMVC
startup. |
static String |
SEPARATORS
Defines the separator characters which can be used between
exception
translator classes. |
static String |
SPRING_CONTEXT_EVENT_TYPE
Defines the default context event type which will be used if one is not explicitly set.
|
static String |
SPRING_SERVLET_EVENT_TYPE
Defines the default servlet event type which will be used if one is not explicitly set.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
addEventOnBypass(javax.servlet.ServletConfig config)
Retrieves a flag indicating whether a Johnson event should be added when SpringMVC initialisation is bypassed
due to previous fatal Spring errors.
|
static boolean |
addEventOnBypass(javax.servlet.ServletContext context)
Retrieves a flag indicating whether a Johnson event should be added when Spring initialisation is bypassed
due to previous fatal errors.
|
static Event |
createDefaultEvent(String eventType,
String message,
Throwable t)
A fail-safe event creator with reliable semantics to fall back on when a more specific
event is
not available. |
static String |
getContextEventType(javax.servlet.ServletContext context)
Examines the provided
ServletContext for a context-param named PARAM_EVENT_TYPE and, if
one is found, returns its value; otherwise the default SPRING_CONTEXT_EVENT_TYPE is returned. |
static String |
getServletEventType(javax.servlet.ServletConfig config)
Examines the provided
ServletConfig for an init-param named PARAM_EVENT_TYPE and, if
one is found, returns its value; otherwise, the default SPRING_SERVLET_EVENT_TYPE is returned. |
static Event |
translateThrowable(javax.servlet.ServletConfig config,
Throwable t) |
static Event |
translateThrowable(javax.servlet.ServletContext servletContext,
Throwable t) |
public static final String PARAM_ADD_EVENT_ON_BYPASS
init-param which may be used for controlling whether an event is added when a portion of
Spring initialisation is bypassed due to previous errors.
Note: This flag does not control whether an event is added when Spring initialisation is not bypassed and fails.
addEventOnBypass(javax.servlet.ServletContext),
Constant Field Valuespublic static final String PARAM_EVENT_TYPE
init-param which may be used for controlling the event type added when Spring events occur.
Where the value must be set depends on the type being initialised.public static final String PARAM_EXCEPTION_TRANSLATOR_CLASS
init-param which can be applied to the ServletContext or ServletConfig to register
one or more EventExceptionTranslator types to be applied to exceptions thrown from Spring or SpringMVC
startup.translateThrowable(ServletConfig, Throwable),
Constant Field Valuespublic static final String SEPARATORS
exception
translator classes.public static final String SPRING_CONTEXT_EVENT_TYPE
public static final String SPRING_SERVLET_EVENT_TYPE
public static boolean addEventOnBypass(@Nonnull javax.servlet.ServletContext context)
By default, an event is not added. If a context-param named PARAM_ADD_EVENT_ON_BYPASS
exists with the value true, then an event
will be added when initialisation is bypassed.
To set this value, add the following to web.xml:
<context-param>
<param-name>johnson.spring.addEventOnBypass</param-name>
<param-value>true</param-value>
</context-param>
Note: If initialisation is not bypassed and fails, this flag does not control whether an event will be
added at that time.context - the servlet contexttrue if an event has been explicitly requested; otherwise, falsepublic static boolean addEventOnBypass(@Nonnull javax.servlet.ServletConfig config)
By default, an event is not added. If an init-param named PARAM_ADD_EVENT_ON_BYPASS
exists, its value (true or false) controls whether an event is added. Otherwise, a fallback check
is made to the context for a context-param.
This means if an event is explicitly requested at the context level, by default it will also be requested at
the servlet level. However, individual servlets can explicitly disable that by setting their init-param
to false.
To set this value, add the following to the declaration for the servlet in web.xml:
<init-param>
<param-name>johnson.spring.addEventOnBypass</param-name>
<param-value>true</param-value>
</init-param>
Note: If initialisation is not bypassed and fails, this flag does not control whether an event will be
added at that time.config - the servlet configurationtrue if an event has been specifically requested, either at the servlet level or at the context
level; otherwise, false@Nonnull public static Event createDefaultEvent(@Nonnull String eventType, @Nonnull String message, @Nonnull Throwable t)
event is
not available.eventType - the event type to usemessage - the message to uset - the exception thrown while attempting to initialise the WebApplicationContextnull@Nonnull public static String getContextEventType(@Nonnull javax.servlet.ServletContext context)
ServletContext for a context-param named PARAM_EVENT_TYPE and, if
one is found, returns its value; otherwise the default SPRING_CONTEXT_EVENT_TYPE is returned.
To set this value, add the following to web.xml:
<context-param>
<param-name>johnson.spring.eventType</param-name>
<param-value>my-spring-context-event-type</param-value>
</context-param>
context - the servlet context@Nonnull public static String getServletEventType(@Nonnull javax.servlet.ServletConfig config)
ServletConfig for an init-param named PARAM_EVENT_TYPE and, if
one is found, returns its value; otherwise, the default SPRING_SERVLET_EVENT_TYPE is returned.
To set this value, add the following to the declaration for the servlet in web.xml:
<init-param>
<param-name>johnson.spring.eventType</param-name>
<param-value>my-spring-servlet-event-type</param-value>
</init-param>
config - the servlet configuration@Nullable public static Event translateThrowable(@Nonnull javax.servlet.ServletConfig config, @Nonnull Throwable t)
Copyright © 2017 Atlassian. All rights reserved.