public void visit ( final WebAppFilter webAppFilter ) { NullArgumentException . validateNotNull ( webAppFilter , "Web app filter" ) ; LOG . debug ( "registering filter: {}" , webAppFilter ) ; final String [ ] urlPatterns = webAppFilter . getUrlPatterns ( ) ; final String [ ] servletNames = webAppFilter . getServletNames ( ) ; if ( ( urlPatterns == null || urlPatterns . length == 0 ) && ( servletNames == null || servletNames . length == 0 ) ) { LOG . warn ( "Filter [" + webAppFilter + "] does not have any mapping. Skipped." ) ; } boolean asyncSupported = false ; if ( webAppFilter . getAsyncSupported ( ) != null ) { asyncSupported = webAppFilter . getAsyncSupported ( ) ; } try { // final Filter filter = RegisterWebAppVisitorHS.newInstance( // Filter.class, bundleClassLoader, // webAppFilter.getFilterClass()); String filterName = webAppFilter . getFilterName ( ) ; Class < ? extends Filter > filterClass = RegisterWebAppVisitorHS . loadClass ( Filter . class , bundleClassLoader , webAppFilter . getFilterClass ( ) ) ; webAppFilter . setFilterClass ( filterClass ) ; Dictionary < String , String > initParams = RegisterWebAppVisitorHS . convertInitParams ( webAppFilter . getInitParams ( ) ) ; DispatcherType [ ] dispatcherTypes = webAppFilter . getDispatcherTypes ( ) . toArray ( new DispatcherType [ webAppFilter . getDispatcherTypes ( ) . size ( ) ] ) ; StringBuilder dispatcherTypeString = new StringBuilder ( ) ; for ( int i = 0 ; i < dispatcherTypes . length ; i ++ ) { dispatcherTypeString . append ( dispatcherTypes [ i ] . name ( ) ) ; if ( i < dispatcherTypes . length ) { dispatcherTypeString . append ( "," ) ; } } initParams . put ( WebContainerConstants . FILTER_MAPPING_DISPATCHER , dispatcherTypeString . toString ( ) ) ; initParams . put ( WebContainerConstants . FILTER_NAME , filterName ) ; webContainer . registerFilter ( filterClass , urlPatterns , servletNames , initParams , asyncSupported , httpContext ) ; //CHECKSTYLE:OFF } catch ( Exception ignore ) { LOG . error ( REGISTRATION_EXCEPTION_SKIPPING , ignore ) ; } //CHECKSTYLE:ON }
Registers filters with web container .