org.springframework.boot.context.embedded
Class ServletListenerRegistrationBean<T extends EventListener>

java.lang.Object
  extended by org.springframework.boot.context.embedded.RegistrationBean
      extended by org.springframework.boot.context.embedded.ServletListenerRegistrationBean<T>
Type Parameters:
T - the type of listener
All Implemented Interfaces:
ServletContextInitializer

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:

Author:
Dave Syer, Phillip Webb

Constructor Summary
ServletListenerRegistrationBean()
          Create a new ServletListenerRegistrationBean instance.
ServletListenerRegistrationBean(T listener)
          Create a new ServletListenerRegistrationBean instance.
 
Method Summary
 T getListener()
           
static boolean isSupportedType(EventListener listener)
          Returns true if the specified listener is one of the supported types.
 void onStartup(javax.servlet.ServletContext servletContext)
          Configure the given ServletContext with any servlets, filters, listeners context-params and attributes necessary for initialization.
 void setListener(T listener)
          Set the listener that will be registered.
 
Methods inherited from class org.springframework.boot.context.embedded.RegistrationBean
addInitParameter, configure, getInitParameters, getOrDeduceName, isAsyncSupported, setAsyncSupported, setInitParameters, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

setListener

public void setListener(T listener)
Set the listener that will be registered.

Parameters:
listener - the listener to register

onStartup

public void onStartup(javax.servlet.ServletContext servletContext)
               throws javax.servlet.ServletException
Description copied from interface: ServletContextInitializer
Configure the given ServletContext with any servlets, filters, listeners context-params and attributes necessary for initialization.

Parameters:
servletContext - the ServletContext to initialize
Throws:
javax.servlet.ServletException - if any call against the given ServletContext throws a ServletException

getListener

public T getListener()

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


Copyright © 2013. All Rights Reserved.