Skip to content

Commit

Permalink
version upgrade to 0.0.6 and refactor apollo-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodyiam committed Jul 25, 2016
1 parent 4c29c11 commit 344595a
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 66 deletions.
2 changes: 1 addition & 1 deletion apollo-adminservice/pom.xml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apollo-assembly/pom.xml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apollo-biz/pom.xml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apollo-buildtools/pom.xml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apollo-client/README.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apollo-client/pom.xml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apollo-common/pom.xml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apollo-configservice/pom.xml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apollo-core/pom.xml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apollo-demo/pom.xml
Expand Up @@ -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>
Expand Down
34 changes: 34 additions & 0 deletions apollo-demo/src/main/java/ApolloConfigDemo.java
@@ -1,6 +1,8 @@
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;

Expand All @@ -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() {
Expand All @@ -37,6 +41,8 @@ public void onChange(ConfigChangeEvent changeEvent) {
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) {
Expand All @@ -48,6 +54,26 @@ private String getConfig(String key) {
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(
Expand All @@ -59,6 +85,14 @@ public static void main(String[] args) throws IOException {
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);
}
Expand Down
54 changes: 0 additions & 54 deletions apollo-demo/src/main/java/ApolloConfigFileDemo.java

This file was deleted.

2 changes: 1 addition & 1 deletion apollo-portal/pom.xml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -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>
Expand Down

0 comments on commit 344595a

Please sign in to comment.