apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaServerProvider.java
private static Map<Env, String> initializeDomains() {
        // find key-value from System Property which key ends with "_meta" (case insensitive)
        Map<String, String> metaServerAddressesFromSystemProperty = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(System.getProperties(), "_meta");
        // remove key's suffix "_meta" (case insensitive)
        metaServerAddressesFromSystemProperty = KeyValueUtils.removeKeySuffix(metaServerAddressesFromSystemProperty, "_meta".length());

        // find key-value from OS environment variable which key ends with "_meta" (case insensitive)
        Map<String, String> metaServerAddressesFromOSEnvironment = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(System.getenv(), "_meta");
        // remove key's suffix "_meta" (case insensitive)
        metaServerAddressesFromOSEnvironment = KeyValueUtils.removeKeySuffix(metaServerAddressesFromOSEnvironment, "_meta".length());

        // find key-value from properties file which key ends with ".meta" (case insensitive)
        Properties properties = new Properties();
        properties = ResourceUtils.readConfigFile(APOLLO_ENV_PROPERTIES_FILE_PATH, properties);
        Map<String, String> metaServerAddressesFromPropertiesFile = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(properties, ".meta");
        // remove key's suffix ".meta" (case insensitive)
        metaServerAddressesFromPropertiesFile = KeyValueUtils.removeKeySuffix(metaServerAddressesFromPropertiesFile, ".meta".length());

        // begin to add key-value, key is environment, value is meta server address matched
        Map<String, String> metaServerAddresses = new HashMap<>();
        // lower priority add first
        metaServerAddresses.putAll(metaServerAddressesFromPropertiesFile);
        metaServerAddresses.putAll(metaServerAddressesFromOSEnvironment);
        metaServerAddresses.putAll(metaServerAddressesFromSystemProperty);

        // add to domain
        Map<Env, String> map = new ConcurrentHashMap<>();
        for(Map.Entry<String, String> entry : metaServerAddresses.entrySet()) {
            // add new environment
            Env env = Env.addEnvironment(entry.getKey());
            // get meta server address value
            String value = entry.getValue();
            // put pair (Env, meta server address)
            map.put(env, value);
        }

        // log all
        logger.info("All environment's meta server address: {}", map);
        return map;
    }
/**
     * load all environment's meta address dynamically when this class loaded by JVM
     */
load all environment's meta address dynamically when this class loaded by JVM
load all environment ' s meta address dynamically when this class loaded by JVM
private static Map<Env, String> initializeDomains() {
        Map<String, String> metaServerAddressesFromSystemProperty = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(System.getProperties(), "_meta");
        metaServerAddressesFromSystemProperty = KeyValueUtils.removeKeySuffix(metaServerAddressesFromSystemProperty, "_meta".length());
        Map<String, String> metaServerAddressesFromOSEnvironment = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(System.getenv(), "_meta");
        metaServerAddressesFromOSEnvironment = KeyValueUtils.removeKeySuffix(metaServerAddressesFromOSEnvironment, "_meta".length());
        Properties properties = new Properties();
        properties = ResourceUtils.readConfigFile(APOLLO_ENV_PROPERTIES_FILE_PATH, properties);
        Map<String, String> metaServerAddressesFromPropertiesFile = KeyValueUtils.filterWithKeyIgnoreCaseEndsWith(properties, ".meta");
        metaServerAddressesFromPropertiesFile = KeyValueUtils.removeKeySuffix(metaServerAddressesFromPropertiesFile, ".meta".length());
        Map<String, String> metaServerAddresses = new HashMap<>();
        metaServerAddresses.putAll(metaServerAddressesFromPropertiesFile);
        metaServerAddresses.putAll(metaServerAddressesFromOSEnvironment);
        metaServerAddresses.putAll(metaServerAddressesFromSystemProperty);
        Map<Env, String> map = new ConcurrentHashMap<>();
        for(Map.Entry<String, String> entry : metaServerAddresses.entrySet()) {
            Env env = Env.addEnvironment(entry.getKey());
            String value = entry.getValue();
            map.put(env, value);
        }
        logger.info("All environment's meta server address: {}", map);
        return map;
    }
private static Map < Env , String > initializeDomains ( ) { Map < String , String > metaServerAddressesFromSystemProperty = KeyValueUtils . filterWithKeyIgnoreCaseEndsWith ( System . getProperties ( ) , "_meta" ) ; metaServerAddressesFromSystemProperty = KeyValueUtils . removeKeySuffix ( metaServerAddressesFromSystemProperty , "_meta" . length ( ) ) ; Map < String , String > metaServerAddressesFromOSEnvironment = KeyValueUtils . filterWithKeyIgnoreCaseEndsWith ( System . getenv ( ) , "_meta" ) ; metaServerAddressesFromOSEnvironment = KeyValueUtils . removeKeySuffix ( metaServerAddressesFromOSEnvironment , "_meta" . length ( ) ) ; Properties properties = new Properties ( ) ; properties = ResourceUtils . readConfigFile ( APOLLO_ENV_PROPERTIES_FILE_PATH , properties ) ; Map < String , String > metaServerAddressesFromPropertiesFile = KeyValueUtils . filterWithKeyIgnoreCaseEndsWith ( properties , ".meta" ) ; metaServerAddressesFromPropertiesFile = KeyValueUtils . removeKeySuffix ( metaServerAddressesFromPropertiesFile , ".meta" . length ( ) ) ; Map < String , String > metaServerAddresses = new HashMap < > ( ) ; metaServerAddresses . putAll ( metaServerAddressesFromPropertiesFile ) ; metaServerAddresses . putAll ( metaServerAddressesFromOSEnvironment ) ; metaServerAddresses . putAll ( metaServerAddressesFromSystemProperty ) ; Map < Env , String > map = new ConcurrentHashMap < > ( ) ; for ( Map . Entry < String , String > entry : metaServerAddresses . entrySet ( ) ) { Env env = Env . addEnvironment ( entry . getKey ( ) ) ; String value = entry . getValue ( ) ; map . put ( env , value ) ; } logger . info ( "All environment's meta server address: {}" , map ) ; return map ; }
load all environment's meta address dynamically when this class loaded by JVM
load all environment ' s meta address dynamically when this class loaded by JVM
// find key-value from System Property which key ends with "_meta" (case insensitive) // remove key's suffix "_meta" (case insensitive) // find key-value from OS environment variable which key ends with "_meta" (case insensitive) // remove key's suffix "_meta" (case insensitive) // find key-value from properties file which key ends with ".meta" (case insensitive) // remove key's suffix ".meta" (case insensitive) // begin to add key-value, key is environment, value is meta server address matched // lower priority add first // add to domain // add new environment // get meta server address value // put pair (Env, meta server address) // log all