T
- the type of listenerpublic class ServletListenerRegistrationBean<T extends EventListener> extends RegistrationBean
ServletContextInitializer
to register EventListener
s in a Servlet
3.0+ container. Similar to the registration
features provided by ServletContext
but with a Spring Bean
friendly design.
This bean can be used to register the following types of listener:
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
ServletListenerRegistrationBean()
Create a new
ServletListenerRegistrationBean instance. |
ServletListenerRegistrationBean(T listener)
Create a new
ServletListenerRegistrationBean instance. |
Modifier and Type | Method and Description |
---|---|
T |
getListener() |
static Set<Class<?>> |
getSupportedTypes() |
static boolean |
isSupportedType(EventListener listener)
Returns
true if the specified listener is one of the supported types. |
void |
onStartup(ServletContext servletContext)
Configure the given
ServletContext with any servlets, filters, listeners
context-params and attributes necessary for initialization. |
void |
setListener(T listener)
Set the listener that will be registered.
|
addInitParameter, configure, getInitParameters, getOrDeduceName, getOrder, isAsyncSupported, isEnabled, setAsyncSupported, setEnabled, setInitParameters, setName, setOrder
public ServletListenerRegistrationBean()
ServletListenerRegistrationBean
instance.public ServletListenerRegistrationBean(T listener)
ServletListenerRegistrationBean
instance.listener
- the listener to registerpublic void setListener(T listener)
listener
- the listener to registerpublic void onStartup(ServletContext servletContext) throws ServletException
ServletContextInitializer
ServletContext
with any servlets, filters, listeners
context-params and attributes necessary for initialization.servletContext
- the ServletContext
to initializeServletException
- if any call against the given ServletContext
throws a ServletException
public T getListener()
public static boolean isSupportedType(EventListener listener)
true
if the specified listener is one of the supported types.listener
- the listener to testCopyright © 2015 Pivotal Software, Inc.. All rights reserved.