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 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:
ServletContextAttributeListenerServletRequestListenerServletRequestAttributeListenerHttpSessionAttributeListenerHttpSessionIdListenerHttpSessionListenerServletContextListener
- Since:
- 1.4.0
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newServletListenerRegistrationBeaninstance.ServletListenerRegistrationBean(T listener) Create a newServletListenerRegistrationBeaninstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringReturn a description of the registration.Return the listener to be registered.Return the supported types for this registration.static booleanisSupportedType(EventListener listener) Returnstrueif the specified listener is one of the supported types.protected voidRegister this bean with the servlet context.voidsetListener(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 newServletListenerRegistrationBeaninstance. -
ServletListenerRegistrationBean
Create a newServletListenerRegistrationBeaninstance.- 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:RegistrationBeanReturn a description of the registration. For example "Servlet resourceServlet"- Specified by:
getDescriptionin classRegistrationBean- Returns:
- a description of the registration
-
register
Description copied from class:RegistrationBeanRegister this bean with the servlet context.- Specified by:
registerin classRegistrationBean- Parameters:
description- a description of the item being registeredservletContext- the servlet context
-
isSupportedType
Returnstrueif 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
-