public static void addConfig ( Config config ) { if ( config == null ) { throw new IllegalArgumentException ( "Config can not be null" ) ; } if ( configNameToConfig . containsKey ( config . getName ( ) ) ) { throw new IllegalArgumentException ( "Config already exists: " + config . getName ( ) ) ; } configNameToConfig . put ( config . getName ( ) , config ) ; /** * Replace the main config if current config name is MAIN_CONFIG_NAME */ if ( MAIN_CONFIG_NAME . equals ( config . getName ( ) ) ) { DbKit . config = config ; Db . init ( DbKit . config . getName ( ) ) ; } /** * The configName may not be MAIN_CONFIG_NAME, * the main config have to set the first comming Config if it is null */ if ( DbKit . config == null ) { DbKit . config = config ; Db . init ( DbKit . config . getName ( ) ) ; } }
Add Config object