public void initBundles ( String resourceDir , String configPath , InitObserver initObs ) throws IOException { // reinitialize our resource dir if it was specified if ( resourceDir != null ) { initResourceDir ( resourceDir ) ; } // load up our configuration Properties config = loadConfig ( configPath ) ; // resolve the configured resource sets List < ResourceBundle > dlist = Lists . newArrayList ( ) ; Enumeration < ? > names = config . propertyNames ( ) ; while ( names . hasMoreElements ( ) ) { String key = ( String ) names . nextElement ( ) ; if ( ! key . startsWith ( RESOURCE_SET_PREFIX ) ) { continue ; } String setName = key . substring ( RESOURCE_SET_PREFIX . length ( ) ) ; String resourceSetType = config . getProperty ( RESOURCE_SET_TYPE_PREFIX + setName , FILE_SET_TYPE ) ; resolveResourceSet ( setName , config . getProperty ( key ) , resourceSetType , dlist ) ; } // if an observer was passed in, then we do not need to block the caller final boolean [ ] shouldWait = new boolean [ ] { false } ; if ( initObs == null ) { // if there's no observer, we'll need to block the caller shouldWait [ 0 ] = true ; initObs = new InitObserver ( ) { public void progress ( int percent , long remaining ) { if ( percent >= 100 ) { synchronized ( this ) { // turn off shouldWait, in case we reached 100% progress before the // calling thread even gets a chance to get to the blocking code, below shouldWait [ 0 ] = false ; notify ( ) ; } } } public void initializationFailed ( Exception e ) { synchronized ( this ) { shouldWait [ 0 ] = false ; notify ( ) ; } } } ; } // start a thread to unpack our bundles Unpacker unpack = new Unpacker ( dlist , initObs ) ; unpack . start ( ) ; if ( shouldWait [ 0 ] ) { synchronized ( initObs ) { if ( shouldWait [ 0 ] ) { try { initObs . wait ( ) ; } catch ( InterruptedException ie ) { log . warning ( "Interrupted while waiting for bundles to unpack." ) ; } } } } }
Initializes the bundle sets to be made available by this resource manager . Applications that wish to make use of resource bundles should call this method after constructing the resource manager .