Class ServletListenerRegistrationBean<T extends EventListener>
java.lang.Object
org.springframework.boot.web.servlet.RegistrationBean
org.springframework.boot.web.servlet.ServletListenerRegistrationBean<T>
- Type Parameters:
T
- the type of listener
- All Implemented Interfaces:
ServletContextInitializer
,org.springframework.core.Ordered
A
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
- Since:
- 1.4.0
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionCreate a newServletListenerRegistrationBean
instance.ServletListenerRegistrationBean
(T listener) Create a newServletListenerRegistrationBean
instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
Return a description of the registration.Return the listener to be registered.Return the supported types for this registration.static boolean
isSupportedType
(EventListener listener) Returnstrue
if the specified listener is one of the supported types.protected void
Register this bean with the servlet context.void
setListener
(T listener) Set the listener that will be registered.Methods inherited from class org.springframework.boot.web.servlet.RegistrationBean
getOrder, isEnabled, onStartup, setEnabled, setOrder
-
Constructor Details
-
ServletListenerRegistrationBean
public ServletListenerRegistrationBean()Create a newServletListenerRegistrationBean
instance. -
ServletListenerRegistrationBean
Create a newServletListenerRegistrationBean
instance.- Parameters:
listener
- the listener to register
-
-
Method Details
-
setListener
Set the listener that will be registered.- Parameters:
listener
- the listener to register
-
getListener
Return the listener to be registered.- Returns:
- the listener to be registered
-
getDescription
Description copied from class:RegistrationBean
Return a description of the registration. For example "Servlet resourceServlet"- Specified by:
getDescription
in classRegistrationBean
- Returns:
- a description of the registration
-
register
Description copied from class:RegistrationBean
Register this bean with the servlet context.- Specified by:
register
in classRegistrationBean
- Parameters:
description
- a description of the item being registeredservletContext
- the servlet context
-
isSupportedType
Returnstrue
if the specified listener is one of the supported types.- Parameters:
listener
- the listener to test- Returns:
- if the listener is of a supported type
-
getSupportedTypes
Return the supported types for this registration.- Returns:
- the supported types
-