public static Config getConfig ( String name , IConfigFactory factory ) { if ( configs == null ) { init ( ) ; } if ( name == null ) { name = DEFAULT_CONFIG_NAME ; } Config got = configs . get ( name ) ; if ( got == null ) { log ( true , "No Config instance named " + name + "... requesting a new one" , null ) ; // recheck in synchronized block to avoid double instantiation // will block concurrent calls to this Config until // the initialization is complete synchronized ( name . intern ( ) ) { got = configs . get ( name ) ; if ( got == null ) { got = factory == null ? load ( name ) : factory . createConfig ( name ) ; if ( got == null ) { log ( false , "Factory " + factory + " returned a null Config" , null ) ; throw new InvalidConfigException ( "Invalid Config returned by " + factory + " factory: null" ) ; } configs . put ( name , got ) ; } } } return got ; }
Returns a Config instance instantiating it on first call . If no factory implementation is provided one will be searched using Service Loader If a Config with given name already exists it will be simply returned