protected ResourceBundle [ ] resolveBundles ( HttpServletRequest req ) { // first look to see if we've cached the bundles for this request in the request object ResourceBundle [ ] bundles = null ; if ( req != null ) { bundles = ( ResourceBundle [ ] ) req . getAttribute ( getBundleCacheName ( ) ) ; } if ( bundles != null ) { return bundles ; } ClassLoader siteLoader = null ; String siteString = null ; if ( _siteIdent != null ) { int siteId = _siteIdent . identifySite ( req ) ; siteString = _siteIdent . getSiteString ( siteId ) ; // grab our site-specific class loader if we have one if ( _siteLoader != null ) { try { siteLoader = _siteLoader . getSiteClassLoader ( siteId ) ; } catch ( IOException ioe ) { log . warning ( "Unable to fetch site-specific classloader" , "siteId" , siteId , "error" , ioe ) ; } } } // try looking up the appropriate bundles bundles = new ResourceBundle [ 2 ] ; // first from the site-specific classloader if ( siteLoader != null ) { bundles [ 0 ] = resolveBundle ( req , _siteBundlePath , siteLoader , false ) ; } else if ( siteString != null ) { // or just try prefixing the site string to the normal bundle path and see if that // turns something up bundles [ 0 ] = resolveBundle ( req , siteString + "_" + _bundlePath , getClass ( ) . getClassLoader ( ) , true ) ; } // then from the default classloader bundles [ 1 ] = resolveBundle ( req , _bundlePath , getClass ( ) . getClassLoader ( ) , false ) ; // if we found either or both bundles, cache 'em if ( bundles [ 0 ] != null || bundles [ 1 ] != null && req != null ) { req . setAttribute ( getBundleCacheName ( ) , bundles ) ; } return bundles ; }
Finds the closest matching resource bundle for the locales specified as preferred by the client in the supplied http request .