static MatchedRequest selectProvider ( IncomingRequest request ) throws HttpErrorPage { URI requestURI = UriUtils . createURI ( request . getRequestLine ( ) . getUri ( ) ) ; String host = UriUtils . extractHost ( requestURI ) . toHostString ( ) ; Header hostHeader = request . getFirstHeader ( HttpHeaders . HOST ) ; if ( hostHeader != null ) { host = hostHeader . getValue ( ) ; } String scheme = requestURI . getScheme ( ) ; String relativeUri = requestURI . getPath ( ) ; String contextPath = request . getContextPath ( ) ; if ( ! StringUtils . isEmpty ( contextPath ) && relativeUri . startsWith ( contextPath ) ) { relativeUri = relativeUri . substring ( contextPath . length ( ) ) ; } Driver driver = null ; UriMapping uriMapping = null ; for ( UriMapping mapping : instances . getUrimappings ( ) . keySet ( ) ) { if ( mapping . matches ( scheme , host , relativeUri ) ) { driver = getInstance ( instances . getUrimappings ( ) . get ( mapping ) ) ; uriMapping = mapping ; break ; } } if ( driver == null ) { throw new HttpErrorPage ( HttpStatus . SC_NOT_FOUND , "Not found" , "No mapping defined for this URI." ) ; } if ( driver . getConfiguration ( ) . isStripMappingPath ( ) ) { relativeUri = DriverFactory . stripMappingPath ( relativeUri , uriMapping ) ; } MatchedRequest context = new MatchedRequest ( driver , relativeUri ) ; LOG . debug ( "Selected {} for scheme:{} host:{} relUrl:{}" , driver , scheme , host , relativeUri ) ; return context ; }
Selects the Driver instance for this request based on the mappings declared in the configuration .