@ Override public InputStream locate ( final String uri ) throws IOException { validState ( standaloneContext != null , "Locator was not initialized properly. StandaloneContext missing." ) ; Exception lastException = null ; final String [ ] contextFolders = standaloneContext . getContextFolders ( ) ; for ( final String contextFolder : contextFolders ) { try { return locateStreamWithContextFolder ( uri , contextFolder ) ; } catch ( final IOException e ) { lastException = e ; LOG . debug ( "Could not locate: {} using contextFolder: {}" , uri , contextFolder ) ; } } final String exceptionMessage = String . format ( "No valid resource '%s' found inside any of contextFolders: %s" , uri , Arrays . toString ( standaloneContext . getContextFolders ( ) ) ) ; throw new IOException ( exceptionMessage , lastException ) ; }
This implementation will try to locate the provided resource inside contextFolder configured by standaloneContext . If a resource cannot be located the next contextFolder from the list will be tried . The first successful result will be returned .