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, Ordered

public class ServletListenerRegistrationBean<T extends EventListener> extends RegistrationBean
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:
Since:
1.4.0
Author:
Dave Syer, Phillip Webb
  • Constructor Details

    • ServletListenerRegistrationBean

      public ServletListenerRegistrationBean()
      Create a new ServletListenerRegistrationBean instance.
    • ServletListenerRegistrationBean

      public ServletListenerRegistrationBean(T listener)
      Create a new ServletListenerRegistrationBean instance.
      Parameters:
      listener - the listener to register
  • Method Details

    • setListener

      public void setListener(T listener)
      Set the listener that will be registered.
      Parameters:
      listener - the listener to register
    • getListener

      public T getListener()
      Return the listener to be registered.
      Returns:
      the listener to be registered
    • getDescription

      protected String getDescription()
      Description copied from class: RegistrationBean
      Return a description of the registration. For example "Servlet resourceServlet"
      Specified by:
      getDescription in class RegistrationBean
      Returns:
      a description of the registration
    • register

      protected void register(String description, ServletContext servletContext)
      Description copied from class: RegistrationBean
      Register this bean with the servlet context.
      Specified by:
      register in class RegistrationBean
      Parameters:
      description - a description of the item being registered
      servletContext - the servlet context
    • isSupportedType

      public static boolean isSupportedType(EventListener listener)
      Returns true 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

      public static Set<Class<?>> getSupportedTypes()
      Return the supported types for this registration.
      Returns:
      the supported types