public void addFilterMapping ( final WebAppFilterMapping filterMapping ) { NullArgumentException . validateNotNull ( filterMapping , "Filter mapping" ) ; NullArgumentException . validateNotNull ( filterMapping . getFilterName ( ) , "Filter name" ) ; final String filterName = filterMapping . getFilterName ( ) ; if ( ! orderedFilters . contains ( filterName ) ) { orderedFilters . add ( filterName ) ; } Set < WebAppFilterMapping > webAppFilterMappings = filterMappings . get ( filterName ) ; if ( webAppFilterMappings == null ) { webAppFilterMappings = new HashSet <> ( ) ; filterMappings . put ( filterName , webAppFilterMappings ) ; } webAppFilterMappings . add ( filterMapping ) ; final WebAppFilter filter = filters . get ( filterName ) ; // can be that the filter is not yet added if ( filter != null ) { if ( filterMapping . getUrlPattern ( ) != null && filterMapping . getUrlPattern ( ) . trim ( ) . length ( ) > 0 ) { filter . addUrlPattern ( filterMapping . getUrlPattern ( ) ) ; } if ( filterMapping . getServletName ( ) != null && filterMapping . getServletName ( ) . trim ( ) . length ( ) > 0 ) { filter . addServletName ( filterMapping . getServletName ( ) ) ; } if ( filterMapping . getDispatcherTypes ( ) != null && ! filterMapping . getDispatcherTypes ( ) . isEmpty ( ) ) { for ( DispatcherType dispatcherType : filterMapping . getDispatcherTypes ( ) ) { filter . addDispatcherType ( dispatcherType ) ; } } } }
Add a filter mapping .