@@ -0,0 +1,2247 @@
+import com.google.common.base.Charsets;%0A%0Aimport com.ctrip.framework.apollo.Config;%0Aimport com.ctrip.framework.apollo.ConfigChangeListener;%0Aimport com.ctrip.framework.apollo.ConfigService;%0Aimport com.ctrip.framework.apollo.model.ConfigChange;%0Aimport com.ctrip.framework.apollo.model.ConfigChangeEvent;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0A%0A/**%0A * @author Jason Song(song_s@ctrip.com)%0A */%0Apublic class SimpleApolloConfigDemo %7B%0A  private static final Logger logger = LoggerFactory.getLogger(SimpleApolloConfigDemo.class);%0A  private String DEFAULT_VALUE = %22undefined%22;%0A  private Config config;%0A%0A  public SimpleApolloConfigDemo() %7B%0A    ConfigChangeListener changeListener = new ConfigChangeListener() %7B%0A      @Override%0A      public void onChange(ConfigChangeEvent changeEvent) %7B%0A        logger.info(%22Changes for namespace %7B%7D%22, changeEvent.getNamespace());%0A        for (String key : changeEvent.changedKeys()) %7B%0A          ConfigChange change = changeEvent.getChange(key);%0A          logger.info(%22Change - key: %7B%7D, oldValue: %7B%7D, newValue: %7B%7D, changeType: %7B%7D%22,%0A              change.getPropertyName(), change.getOldValue(), change.getNewValue(),%0A              change.getChangeType());%0A        %7D%0A      %7D%0A    %7D;%0A    config = ConfigService.getAppConfig();%0A    config.addChangeListener(changeListener);%0A  %7D%0A%0A  private String getConfig(String key) %7B%0A    String result = config.getProperty(key, DEFAULT_VALUE);%0A    logger.info(String.format(%22Loading key : %25s with value: %25s%22, key, result));%0A    return result;%0A  %7D%0A%0A  public static void main(String%5B%5D args) throws IOException %7B%0A    SimpleApolloConfigDemo apolloConfigDemo = new SimpleApolloConfigDemo();%0A    System.out.println(%0A        %22Apollo Config Demo. Please input key to get the value. Input quit to exit.%22);%0A    while (true) %7B%0A      System.out.print(%22%3E %22);%0A      String input = new BufferedReader(new InputStreamReader(System.in, Charsets.UTF_8)).readLine();%0A      if (input == null %7C%7C input.length() == 0) %7B%0A        continue;%0A      %7D%0A      input = input.trim();%0A      if (input.equalsIgnoreCase(%22quit%22)) %7B%0A        System.exit(0);%0A      %7D%0A      apolloConfigDemo.getConfig(input);%0A    %7D%0A  %7D%0A%7D%0A

add SimpleApolloConfigDemo