Commit 344595aa by Jason Song

version upgrade to 0.0.6 and refactor apollo-demo

parent 4c29c113
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apollo-biz</artifactId> <artifactId>apollo-biz</artifactId>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -88,7 +88,7 @@ If you need this functionality, you could specify the cluster as follows: ...@@ -88,7 +88,7 @@ If you need this functionality, you could specify the cluster as follows:
<dependency> <dependency>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId> <artifactId>apollo-client</artifactId>
<version>0.0.5</version> <version>0.0.6</version>
</dependency> </dependency>
## III. Client Usage ## III. Client Usage
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apollo-demo</artifactId> <artifactId>apollo-demo</artifactId>
......
import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigChangeListener; import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.ConfigFile;
import com.ctrip.framework.apollo.ConfigService; 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.ConfigChange;
import com.ctrip.framework.apollo.model.ConfigChangeEvent; import com.ctrip.framework.apollo.model.ConfigChangeEvent;
...@@ -19,6 +21,8 @@ public class ApolloConfigDemo { ...@@ -19,6 +21,8 @@ public class ApolloConfigDemo {
private String DEFAULT_VALUE = "undefined"; private String DEFAULT_VALUE = "undefined";
private Config config; private Config config;
private Config publicConfig; private Config publicConfig;
private ConfigFile applicationConfigFile;
private ConfigFile xmlConfigFile;
public ApolloConfigDemo() { public ApolloConfigDemo() {
ConfigChangeListener changeListener = new ConfigChangeListener() { ConfigChangeListener changeListener = new ConfigChangeListener() {
...@@ -37,6 +41,8 @@ public class ApolloConfigDemo { ...@@ -37,6 +41,8 @@ public class ApolloConfigDemo {
config.addChangeListener(changeListener); config.addChangeListener(changeListener);
publicConfig = ConfigService.getConfig("FX.apollo"); publicConfig = ConfigService.getConfig("FX.apollo");
publicConfig.addChangeListener(changeListener); publicConfig.addChangeListener(changeListener);
applicationConfigFile = ConfigService.getConfigFile("application", ConfigFileFormat.Properties);
xmlConfigFile = ConfigService.getConfigFile("datasources", ConfigFileFormat.XML);
} }
private String getConfig(String key) { private String getConfig(String key) {
...@@ -48,6 +54,26 @@ public class ApolloConfigDemo { ...@@ -48,6 +54,26 @@ public class ApolloConfigDemo {
return result; 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 { public static void main(String[] args) throws IOException {
ApolloConfigDemo apolloConfigDemo = new ApolloConfigDemo(); ApolloConfigDemo apolloConfigDemo = new ApolloConfigDemo();
System.out.println( System.out.println(
...@@ -59,6 +85,14 @@ public class ApolloConfigDemo { ...@@ -59,6 +85,14 @@ public class ApolloConfigDemo {
continue; continue;
} }
input = input.trim(); input = input.trim();
if (input.equalsIgnoreCase("application")) {
apolloConfigDemo.print("application");
continue;
}
if (input.equalsIgnoreCase("xml")) {
apolloConfigDemo.print("xml");
continue;
}
if (input.equalsIgnoreCase("quit")) { if (input.equalsIgnoreCase("quit")) {
System.exit(0); 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 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>0.0.6-SNAPSHOT</version> <version>0.0.6</version>
<name>Apollo</name> <name>Apollo</name>
<packaging>pom</packaging> <packaging>pom</packaging>
<description>Ctrip Configuration Center</description> <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