Example usage for org.springframework.boot.web.servlet ServletRegistrationBean getServletName

List of usage examples for org.springframework.boot.web.servlet ServletRegistrationBean getServletName

Introduction

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

Prototype

public String getServletName() 

Source Link

Document

Returns the servlet name that will be registered.

Usage

From source file:org.springframework.boot.web.servlet.AbstractFilterRegistrationBean.java

/**
 * Configure registration settings. Subclasses can override this method to perform
 * additional configuration if required.
 * @param registration the registration//from ww w . jav  a 2  s . c  o  m
 */
protected void configure(FilterRegistration.Dynamic registration) {
    super.configure(registration);
    EnumSet<DispatcherType> dispatcherTypes = this.dispatcherTypes;
    if (dispatcherTypes == null) {
        dispatcherTypes = (isAsyncSupported() ? ASYNC_DISPATCHER_TYPES : NON_ASYNC_DISPATCHER_TYPES);
    }
    Set<String> servletNames = new LinkedHashSet<String>();
    for (ServletRegistrationBean servletRegistrationBean : this.servletRegistrationBeans) {
        servletNames.add(servletRegistrationBean.getServletName());
    }
    servletNames.addAll(this.servletNames);
    if (servletNames.isEmpty() && this.urlPatterns.isEmpty()) {
        this.logger.info(
                "Mapping filter: '" + registration.getName() + "' to: " + Arrays.asList(DEFAULT_URL_MAPPINGS));
        registration.addMappingForUrlPatterns(dispatcherTypes, this.matchAfter, DEFAULT_URL_MAPPINGS);
    } else {
        if (!servletNames.isEmpty()) {
            this.logger.info("Mapping filter: '" + registration.getName() + "' to servlets: " + servletNames);
            registration.addMappingForServletNames(dispatcherTypes, this.matchAfter,
                    servletNames.toArray(new String[servletNames.size()]));
        }
        if (!this.urlPatterns.isEmpty()) {
            this.logger.info("Mapping filter: '" + registration.getName() + "' to urls: " + this.urlPatterns);
            registration.addMappingForUrlPatterns(dispatcherTypes, this.matchAfter,
                    this.urlPatterns.toArray(new String[this.urlPatterns.size()]));
        }
    }
}