Browse Source

version upgrade to 0.0.6 and refactor apollo-demo

Jason Song 8 years ago
parent
commit
344595aa28

+ 1 - 1
apollo-adminservice/pom.xml

@@ -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>

+ 1 - 1
apollo-assembly/pom.xml

@@ -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>

+ 1 - 1
apollo-biz/pom.xml

@@ -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>

+ 1 - 1
apollo-buildtools/pom.xml

@@ -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>

+ 1 - 1
apollo-client/README.md

@@ -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

+ 1 - 1
apollo-client/pom.xml

@@ -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>

+ 1 - 1
apollo-common/pom.xml

@@ -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>

+ 1 - 1
apollo-configservice/pom.xml

@@ -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>

+ 1 - 1
apollo-core/pom.xml

@@ -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>

+ 1 - 1
apollo-demo/pom.xml

@@ -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>

+ 34 - 0
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;
 
@@ -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);
       }

+ 0 - 54
apollo-demo/src/main/java/ApolloConfigFileDemo.java

@@ -1,54 +0,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);
-      }
-    }
-  }
-}

+ 1 - 1
apollo-portal/pom.xml

@@ -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>

+ 1 - 1
pom.xml

@@ -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>