package com.ctrip.apollo.core;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import com.ctrip.apollo.core.enums.Env;
import com.ctrip.apollo.core.utils.ResourceUtils;

/**
 * The meta domain will load the meta server from System environment first, if not exist, will load
 * from apollo-env.properties. If neither exists, will load the default meta url.
 * 
 * Currently, apollo supports local/dev/fat/uat/lpt/pro environments.
 */
public class MetaDomainConsts {

  private static Map<Env, String> domains = new HashMap<>();

  public static final String DEFAULT_META_URL = "http://localhost:8080";

  static {
    Properties prop = new Properties();
    prop = ResourceUtils.readConfigFile("apollo-env.properties", prop);
    Map<String, String> env = System.getenv();
    domains.put(Env.LOCAL,
        env.getOrDefault("local_meta", prop.getProperty("local.meta", DEFAULT_META_URL)));
    domains.put(Env.DEV,
        env.getOrDefault("dev_meta", prop.getProperty("dev.meta", DEFAULT_META_URL)));
    domains.put(Env.FAT,
        env.getOrDefault("fat_meta", prop.getProperty("fat.meta", DEFAULT_META_URL)));
    domains.put(Env.UAT,
        env.getOrDefault("uat_meta", prop.getProperty("uat.meta", DEFAULT_META_URL)));
    domains.put(Env.LPT,
        env.getOrDefault("lpt_meta", prop.getProperty("lpt.meta", DEFAULT_META_URL)));
    domains.put(Env.PRO,
        env.getOrDefault("pro_meta", prop.getProperty("pro.meta", DEFAULT_META_URL)));
  }

  public static String getDomain(Env env) {
    return domains.get(env);
  }
}

@@ -458,16 +458,61 @@
 ts.%0A */%0A
+@SuppressWarnings(%7B%22rawtypes%22, %22unchecked%22%7D)%0A
 public c
@@ -562,22 +562,22 @@
 ap%3CEnv, 
-String
+Object
 %3E domain
@@ -806,24 +806,8 @@
  Map
-%3CString, String%3E
  env
@@ -819,19 +819,26 @@
 stem.get
-env
+Properties
 ();%0A    
@@ -1571,16 +1571,31 @@
  return 
+String.valueOf(
 domains.
@@ -1602,16 +1602,17 @@
 get(env)
+)
 ;%0A  %7D%0A%7D%0A

Fix get env properties bugs