Commit a535b38a by 张乐 Committed by GitHub

Merge pull request #344 from nobodyiam/0.0.6

version upgrade to 0.0.6 and refactor apollo-demo
parents 4c29c113 344595aa
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<artifactId>apollo</artifactId>
<groupId>com.ctrip.framework.apollo</groupId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apollo-biz</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -88,7 +88,7 @@ If you need this functionality, you could specify the cluster as follows:
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
</dependency>
## III. Client Usage
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<artifactId>apollo</artifactId>
<groupId>com.ctrip.framework.apollo</groupId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apollo-demo</artifactId>
......
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.ConfigFile;
import com.ctrip.framework.apollo.ConfigService;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.model.ConfigChange;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
......@@ -19,6 +21,8 @@ public class ApolloConfigDemo {
private String DEFAULT_VALUE = "undefined";
private Config config;
private Config publicConfig;
private ConfigFile applicationConfigFile;
private ConfigFile xmlConfigFile;
public ApolloConfigDemo() {
ConfigChangeListener changeListener = new ConfigChangeListener() {
......@@ -37,6 +41,8 @@ public class ApolloConfigDemo {
config.addChangeListener(changeListener);
publicConfig = ConfigService.getConfig("FX.apollo");
publicConfig.addChangeListener(changeListener);
applicationConfigFile = ConfigService.getConfigFile("application", ConfigFileFormat.Properties);
xmlConfigFile = ConfigService.getConfigFile("datasources", ConfigFileFormat.XML);
}
private String getConfig(String key) {
......@@ -48,6 +54,26 @@ public class ApolloConfigDemo {
return result;
}
private void print(String namespace) {
switch (namespace) {
case "application":
print(applicationConfigFile);
return;
case "xml":
print(xmlConfigFile);
return;
}
}
private void print(ConfigFile configFile) {
if (!configFile.hasContent()) {
System.out.println("No config file content found for " + configFile.getNamespace());
return;
}
System.out.println("=== Config File Content for " + configFile.getNamespace() + " is as follows: ");
System.out.println(configFile.getContent());
}
public static void main(String[] args) throws IOException {
ApolloConfigDemo apolloConfigDemo = new ApolloConfigDemo();
System.out.println(
......@@ -59,6 +85,14 @@ public class ApolloConfigDemo {
continue;
}
input = input.trim();
if (input.equalsIgnoreCase("application")) {
apolloConfigDemo.print("application");
continue;
}
if (input.equalsIgnoreCase("xml")) {
apolloConfigDemo.print("xml");
continue;
}
if (input.equalsIgnoreCase("quit")) {
System.exit(0);
}
......
import com.ctrip.framework.apollo.ConfigFile;
import com.ctrip.framework.apollo.ConfigService;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.Properties;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public class ApolloConfigFileDemo {
private static final Logger logger = LoggerFactory.getLogger(ApolloConfigDemo.class);
private ConfigFile configFile;
private String namespace = "application";
public ApolloConfigFileDemo() {
configFile = ConfigService.getConfigFile(namespace, ConfigFileFormat.Properties);
}
private void print() {
if (!configFile.hasContent()) {
System.out.println("No config file content found for " + namespace);
return;
}
System.out.println("=== Config File Content for " + namespace + " is as follows: ");
System.out.println(configFile.getContent());
}
public static void main(String[] args) throws IOException {
ApolloConfigFileDemo apolloConfigFileDemo = new ApolloConfigFileDemo();
System.out.println(
"Apollo Config File Demo. Please input print to get the config file content.");
while (true) {
System.out.print("> ");
String input = new BufferedReader(new InputStreamReader(System.in)).readLine();
if (input == null || input.length() == 0) {
continue;
}
input = input.trim();
if (input.equalsIgnoreCase("print")) {
apolloConfigFileDemo.print();
}
if (input.equalsIgnoreCase("quit")) {
System.exit(0);
}
}
}
}
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.6</version>
<name>Apollo</name>
<packaging>pom</packaging>
<description>Ctrip Configuration Center</description>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment