T - the type of listenerpublic class ServletListenerRegistrationBean<T extends EventListener> extends RegistrationBean
ServletContextInitializer to register EventListeners 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:
ServletContextAttributeListenerServletRequestListenerServletRequestAttributeListenerHttpSessionAttributeListenerHttpSessionListenerServletContextListener| 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()
Return the supported types for this registration.
|
static boolean |
isSupportedType(EventListener listener)
Returns
true if the specified listener is one of the supported types. |
void |
onStartup(javax.servlet.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, setOrderpublic 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(javax.servlet.ServletContext servletContext)
throws javax.servlet.ServletException
ServletContextInitializerServletContext with any servlets, filters, listeners
context-params and attributes necessary for initialization.servletContext - the ServletContext to initializejavax.servlet.ServletException - if any call against the given ServletContext
throws a ServletExceptionpublic T getListener()
public static boolean isSupportedType(EventListener listener)
true if the specified listener is one of the supported types.listener - the listener to testCopyright © 2017 Pivotal Software, Inc.. All rights reserved.