T
- the type of listenerpublic class ServletListenerRegistrationBean<T extends java.util.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:
ServletContextAttributeListener
ServletRequestListener
ServletRequestAttributeListener
HttpSessionAttributeListener
HttpSessionIdListener
HttpSessionListener
ServletContextListener
Constructor and Description |
---|
ServletListenerRegistrationBean()
Create a new
ServletListenerRegistrationBean instance. |
ServletListenerRegistrationBean(T listener)
Create a new
ServletListenerRegistrationBean instance. |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
getDescription()
Return a description of the registration.
|
T |
getListener()
Return the listener to be registered.
|
static java.util.Set<java.lang.Class<?>> |
getSupportedTypes()
Return the supported types for this registration.
|
static boolean |
isSupportedType(java.util.EventListener listener)
Returns
true if the specified listener is one of the supported types. |
protected void |
register(java.lang.String description,
javax.servlet.ServletContext servletContext)
Register this bean with the servlet context.
|
void |
setListener(T listener)
Set the listener that will be registered.
|
getOrder, isEnabled, onStartup, setEnabled, 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 T getListener()
protected java.lang.String getDescription()
RegistrationBean
getDescription
in class RegistrationBean
protected void register(java.lang.String description, javax.servlet.ServletContext servletContext)
RegistrationBean
register
in class RegistrationBean
description
- a description of the item being registeredservletContext
- the servlet contextpublic static boolean isSupportedType(java.util.EventListener listener)
true
if the specified listener is one of the supported types.listener
- the listener to testpublic static java.util.Set<java.lang.Class<?>> getSupportedTypes()