Example usage for org.springframework.boot.web.servlet ServletListenerRegistrationBean setEnabled

List of usage examples for org.springframework.boot.web.servlet ServletListenerRegistrationBean setEnabled

Introduction

In this page you can find the example usage for org.springframework.boot.web.servlet ServletListenerRegistrationBean setEnabled.

Prototype

public void setEnabled(boolean enabled) 

Source Link

Document

Flag to indicate that the registration is enabled.

Usage

From source file:net.bull.javamelody.JavaMelodyAutoConfiguration.java

/**
 * Registers the JavaMelody {@link SessionListener}.
 * @param servletContext ServletContext//from   www .  j  a  v  a 2  s.  com
 * @return ServletListenerRegistrationBean
 */
@Bean
public ServletListenerRegistrationBean<EventListener> monitoringSessionListener(ServletContext servletContext) {
    final ServletListenerRegistrationBean<EventListener> servletListenerRegistrationBean = new ServletListenerRegistrationBean<EventListener>(
            new SessionListener());
    if (servletContext.getFilterRegistration("javamelody") != null) {
        // if webapp deployed as war in a container with MonitoringFilter and SessionListener already added by web-fragment.xml,
        // do not add again
        servletListenerRegistrationBean.setEnabled(false);
    }
    return servletListenerRegistrationBean;
}