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:
ServletContextAttributeListener
ServletRequestListener
ServletRequestAttributeListener
HttpSessionAttributeListener
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 String |
getDescription()
Return a description of the registration.
|
T |
getListener()
Return the listener to be registered.
|
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. |
protected void |
register(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 String getDescription()
RegistrationBean
getDescription
in class RegistrationBean
protected void register(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(EventListener listener)
true
if the specified listener is one of the supported types.listener
- the listener to testCopyright © 2020 Pivotal Software, Inc.. All rights reserved.