Przeglądaj źródła

client and core: delete apollo dependency

knightliao 9 lat temu
rodzic
commit
ecec04e421
47 zmienionych plików z 2248 dodań i 446 usunięć
  1. 7 5
      disconf-client-spring/.gitignore
  2. 6 0
      disconf-client-spring/README.md
  3. 25 0
      disconf-client-spring/deploy/package-jar.xml
  4. 348 0
      disconf-client-spring/pom.xml
  5. 2 2
      disconf-client/pom.xml
  6. 1 1
      disconf-client/src/main/java/com/baidu/disconf/client/DisconfMgrBean.java
  7. 2 2
      disconf-client/src/main/java/com/baidu/disconf/client/common/model/DisconfCenterFile.java
  8. 1 1
      disconf-client/src/main/java/com/baidu/disconf/client/config/DisClientConfig.java
  9. 1 1
      disconf-client/src/main/java/com/baidu/disconf/client/config/DisClientSysConfig.java
  10. 3 3
      disconf-client/src/main/java/com/baidu/disconf/client/config/inner/DisInnerConfigHelper.java
  11. 1 1
      disconf-client/src/main/java/com/baidu/disconf/client/core/filetype/impl/DisconfPropertiesProcessorImpl.java
  12. 1 1
      disconf-client/src/main/java/com/baidu/disconf/client/core/processor/impl/DisconfFileCoreProcessorImpl.java
  13. 1 1
      disconf-client/src/main/java/com/baidu/disconf/client/fetcher/impl/FetcherMgrImpl.java
  14. 1 1
      disconf-client/src/main/java/com/baidu/disconf/client/store/processor/impl/DisconfStoreFileProcessorImpl.java
  15. 3 3
      disconf-client/src/main/java/com/baidu/disconf/client/store/processor/impl/DisconfStoreItemProcessorImpl.java
  16. 3 3
      disconf-client/src/main/java/com/baidu/disconf/client/support/DisconfAutowareConfig.java
  17. 1 1
      disconf-client/src/main/java/com/baidu/disconf/client/support/EmailConstants.java
  18. 192 0
      disconf-client/src/main/java/com/baidu/disconf/client/utils/ClassUtils.java
  19. 154 0
      disconf-client/src/main/java/com/baidu/disconf/client/utils/ConfigLoaderUtils.java
  20. 0 1
      disconf-client/src/main/java/com/baidu/disconf/client/utils/MethodUtils.java
  21. 829 0
      disconf-client/src/main/java/com/baidu/disconf/client/utils/StringUtil.java
  22. 5 5
      disconf-client/src/main/java/com/baidu/disconf/client/watch/impl/WatchMgrImpl.java
  23. 2 2
      disconf-client/src/test/java/com/baidu/disconf/client/test/DisconfMgrTestCase.java
  24. 4 4
      disconf-client/src/test/java/com/baidu/disconf/client/test/common/BaseSpringMockTestCase.java
  25. 4 4
      disconf-client/src/test/java/com/baidu/disconf/client/test/common/BaseSpringTestCase.java
  26. 2 2
      disconf-client/src/test/java/com/baidu/disconf/client/test/scan/inner/ScanPackTestCase.java
  27. 62 0
      disconf-client/src/test/java/com/baidu/disconf/client/test/utils/NetUtils.java
  28. 0 8
      disconf-core/pom.xml
  29. 2 2
      disconf-core/src/main/java/com/baidu/disconf/core/common/restful/impl/RestfulMgrImpl.java
  30. 1 1
      disconf-core/src/main/java/com/baidu/disconf/core/common/restful/type/FetchConfFile.java
  31. 67 0
      disconf-core/src/main/java/com/baidu/disconf/core/common/utils/ClassLoaderUtil.java
  32. 120 0
      disconf-core/src/main/java/com/baidu/disconf/core/common/utils/FileUtils.java
  33. 48 0
      disconf-core/src/main/java/com/baidu/disconf/core/common/utils/GsonUtils.java
  34. 54 0
      disconf-core/src/main/java/com/baidu/disconf/core/common/utils/MachineInfo.java
  35. 224 0
      disconf-core/src/main/java/com/baidu/disconf/core/common/utils/OsUtil.java
  36. 34 0
      disconf-core/src/main/java/com/baidu/disconf/core/common/utils/ZooUtils.java
  37. 2 2
      disconf-core/src/main/java/com/baidu/disconf/core/common/zookeeper/ZookeeperMgr.java
  38. 1 1
      disconf-core/src/test/java/com/baidu/disconf/core/test/TestSuite.java
  39. 29 29
      disconf-core/src/test/java/com/baidu/disconf/core/test/common/BaseCoreTestCase.java
  40. 1 1
      disconf-core/src/test/java/com/baidu/disconf/core/test/utils/MyStringUtilsTestCase.java
  41. 0 7
      disconf-tool/README.md
  42. 0 71
      disconf-tool/pom.xml
  43. 0 85
      disconf-tool/src/main/java/com/baidu/disconf/tool/context/ContextMgr.java
  44. 0 165
      disconf-tool/src/test/java/com/baidu/disconf/tool/context/test/ContextMgrTestCase.java
  45. 0 17
      disconf-tool/src/test/java/com/baidu/disconf/tool/test/TestSuite.java
  46. 1 0
      disconf-web/pom.xml
  47. 3 13
      pom.xml

+ 7 - 5
disconf-tool/.gitignore → disconf-client-spring/.gitignore

@@ -1,12 +1,14 @@
+/target
 /bin
+/.settings
 /.classpath
 /.project
-/target
-/.settings
-/doc
-/*.class
-/.README.md.html
+/disconf
+/log
+/.pydevproject
 /pom.xml.releaseBackup
+/coverage-report
+/tmp
 /*.iml
 /.DS_Store
 .idea

+ 6 - 0
disconf-client-spring/README.md

@@ -0,0 +1,6 @@
+disconf-client
+=======
+
+分布式配置管理客户端模块
+
+

+ 25 - 0
disconf-client-spring/deploy/package-jar.xml

@@ -0,0 +1,25 @@
+<assembly
+    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+
+    <id>package</id>
+
+    <formats>
+        <format>jar</format>
+    </formats>
+
+    <includeBaseDirectory>false</includeBaseDirectory>
+
+    <fileSets>
+        <fileSet>
+            <directory>target/classes</directory>
+            <excludes>
+                <exclude>disconf.properties</exclude>
+                <exclude>logback.xml</exclude>
+            </excludes>
+            <outputDirectory>/</outputDirectory>
+        </fileSet>
+    </fileSets>
+
+</assembly>

+ 348 - 0
disconf-client-spring/pom.xml

@@ -0,0 +1,348 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>disconf-client</artifactId>
+    <packaging>jar</packaging>
+    <version>${disconf-client.version}</version>
+
+    <parent>
+        <groupId>com.baidu.disconf</groupId>
+        <artifactId>disconf-base</artifactId>
+        <version>2.6.28</version>
+    </parent>
+
+    <licenses>
+        <license>
+            <name>Apache 2</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+            <comments>A business-friendly OSS license</comments>
+        </license>
+    </licenses>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.baidu.disconf</groupId>
+            <artifactId>disconf-core</artifactId>
+            <version>${disconf-core.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.baidu.disconf</groupId>
+            <artifactId>disconf-core</artifactId>
+            <version>${disconf-core.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- common dependencies -->
+
+        <dependency>
+            <groupId>org.apache.zookeeper</groupId>
+            <artifactId>zookeeper</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.sun.jmx</groupId>
+                    <artifactId>jmxri</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.sun.jdmk</groupId>
+                    <artifactId>jmxtools</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>javax.jms</groupId>
+                    <artifactId>jms</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-client</artifactId>
+            <version>2.0-m13</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+            <version>2.0-rc1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.reflections</groupId>
+            <artifactId>reflections</artifactId>
+            <version>0.9.9-RC1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjtools</artifactId>
+        </dependency>
+
+        <!-- log dependencies -->
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <!-- ================ test ================ -->
+
+        <dependency>
+            <groupId>com.googlecode.jmockit</groupId>
+            <artifactId>jmockit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.googlecode.jmockit</groupId>
+            <artifactId>jmockit-coverage</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.tomakehurst</groupId>
+            <artifactId>wiremock</artifactId>
+            <scope>test</scope>
+            <!-- Include this if you have dependency conflicts for Guava, 
+                Jetty, Jackson or Apache HTTP Client -->
+            <classifier>standalone</classifier>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- ================ provided ================ -->
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aop</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+
+        <defaultGoal>package</defaultGoal>
+        <finalName>${project.artifactId}</finalName>
+        <outputDirectory>target/classes</outputDirectory>
+
+        <resources>
+            <resource>
+                <directory>${project.basedir}/src/main/java</directory>
+                <excludes>
+                    <exclude>**/*.java</exclude>
+                </excludes>
+            </resource>
+            <resource>
+                <directory>${project.basedir}/src/main/resources</directory>
+                <includes>
+                    <include>*.*</include>
+                </includes>
+            </resource>
+        </resources>
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>${source.version}</source>
+                    <target>${target.version}</target>
+                    <encoding>${encoding}</encoding>
+                    <failOnError>true</failOnError>
+                    <showDeprecation>true</showDeprecation>
+                    <showWarnings>true</showWarnings>
+                    <compilerArguments>
+                        <verbose/>
+                        <bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
+                    </compilerArguments>
+                </configuration>
+
+                <dependencies>
+                    <dependency>
+                        <groupId>org.codehaus.plexus</groupId>
+                        <artifactId>plexus-compiler-javac</artifactId>
+                        <version>1.8.1</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>*.properties</exclude>
+                        <exclude>**/*.properties</exclude>
+                        <exclude>conf/**</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.3</version>
+                <executions>
+
+                    <execution>
+                        <id>make-jar</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <configuration>
+                            <appendAssemblyId>false</appendAssemblyId>
+                            <descriptors>
+                                <descriptor>deploy/package-jar.xml</descriptor>
+                            </descriptors>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <name>disconf-client</name>
+    <url>https://github.com/knightliao/disconf/tree/master/disconf-client</url>
+    <description>https://github.com/knightliao/disconf/tree/master/disconf-client</description>
+
+    <organization>
+        <name>Baidu</name>
+        <url>http://www.example.com</url>
+    </organization>
+
+    <scm>
+        <url>scm:git:git@github.com:knightliao/disconf</url>
+        <connection>scm:git:git@github.com:knightliao/disconf</connection>
+        <tag>disconf-client</tag>
+    </scm>
+
+    <profiles>
+        <profile>
+            <id>release</id>
+            <distributionManagement>
+                <snapshotRepository>
+                    <id>nexus-release</id>
+                    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
+                </snapshotRepository>
+                <repository>
+                    <id>nexus-release</id>
+                    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
+                </repository>
+            </distributionManagement>
+            <build>
+                <plugins>
+                    <!-- Source -->
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-source-plugin</artifactId>
+                        <version>2.2.1</version>
+                        <executions>
+                            <execution>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>jar-no-fork</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <!-- Javadoc -->
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-javadoc-plugin</artifactId>
+                        <version>2.9.1</version>
+                        <executions>
+                            <execution>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>jar</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-gpg-plugin</artifactId>
+                        <version>1.5</version>
+                        <executions>
+                            <execution>
+                                <id>sign-artifacts</id>
+                                <phase>verify</phase>
+                                <goals>
+                                    <goal>sign</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>

+ 2 - 2
disconf-client/pom.xml

@@ -107,13 +107,13 @@
         <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-core</artifactId>
-            <scope>test</scope>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
-            <scope>test</scope>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>

+ 1 - 1
disconf-client/src/main/java/com/baidu/disconf/client/DisconfMgrBean.java

@@ -12,7 +12,7 @@ import org.springframework.core.Ordered;
 import org.springframework.core.PriorityOrdered;
 
 import com.baidu.disconf.client.store.inner.DisconfCenterHostFilesStore;
-import com.github.knightliao.apollo.utils.common.StringUtil;
+import com.baidu.disconf.client.utils.StringUtil;
 
 /**
  * 第一次扫描,静态扫描

+ 2 - 2
disconf-client/src/main/java/com/baidu/disconf/client/common/model/DisconfCenterFile.java

@@ -6,8 +6,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import com.baidu.disconf.client.common.constants.SupportFileTypeEnum;
-import com.github.knightliao.apollo.utils.io.OsUtil;
-import com.github.knightliao.apollo.utils.tool.ClassLoaderUtil;
+import com.baidu.disconf.core.common.utils.ClassLoaderUtil;
+import com.baidu.disconf.core.common.utils.OsUtil;
 
 /**
  * 配置文件表示

+ 1 - 1
disconf-client/src/main/java/com/baidu/disconf/client/config/DisClientConfig.java

@@ -8,7 +8,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.baidu.disconf.client.config.inner.DisInnerConfigAnnotation;
-import com.baidu.disconf.client.utils.DisconfAutowareConfig;
+import com.baidu.disconf.client.support.DisconfAutowareConfig;
 import com.baidu.disconf.core.common.constants.Constants;
 
 /**

+ 1 - 1
disconf-client/src/main/java/com/baidu/disconf/client/config/DisClientSysConfig.java

@@ -4,7 +4,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.baidu.disconf.client.config.inner.DisInnerConfigAnnotation;
-import com.baidu.disconf.client.utils.DisconfAutowareConfig;
+import com.baidu.disconf.client.support.DisconfAutowareConfig;
 
 /**
  * Disconf 系统自带的配置

+ 3 - 3
disconf-client/src/main/java/com/baidu/disconf/client/config/inner/DisInnerConfigHelper.java

@@ -10,9 +10,9 @@ import org.slf4j.LoggerFactory;
 
 import com.baidu.disconf.client.config.DisClientConfig;
 import com.baidu.disconf.client.config.DisClientSysConfig;
-import com.github.knightliao.apollo.utils.common.StringUtil;
-import com.github.knightliao.apollo.utils.io.OsUtil;
-import com.github.knightliao.apollo.utils.tool.ClassLoaderUtil;
+import com.baidu.disconf.client.utils.StringUtil;
+import com.baidu.disconf.core.common.utils.ClassLoaderUtil;
+import com.baidu.disconf.core.common.utils.OsUtil;
 
 /**
  * 用户配置、系统配置 的校验

+ 1 - 1
disconf-client/src/main/java/com/baidu/disconf/client/core/filetype/impl/DisconfPropertiesProcessorImpl.java

@@ -5,7 +5,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import com.baidu.disconf.client.core.filetype.DisconfFileTypeProcessor;
-import com.github.knightliao.apollo.utils.config.ConfigLoaderUtils;
+import com.baidu.disconf.client.utils.ConfigLoaderUtils;
 
 /**
  * Properties 处理器

+ 1 - 1
disconf-client/src/main/java/com/baidu/disconf/client/core/processor/impl/DisconfFileCoreProcessorImpl.java

@@ -17,7 +17,7 @@ import com.baidu.disconf.client.store.DisconfStoreProcessorFactory;
 import com.baidu.disconf.client.store.processor.model.DisconfValue;
 import com.baidu.disconf.client.watch.WatchMgr;
 import com.baidu.disconf.core.common.constants.DisConfigTypeEnum;
-import com.github.knightliao.apollo.utils.data.GsonUtils;
+import com.baidu.disconf.core.common.utils.GsonUtils;
 
 /**
  * 配置文件处理器实现

+ 1 - 1
disconf-client/src/main/java/com/baidu/disconf/client/fetcher/impl/FetcherMgrImpl.java

@@ -12,7 +12,7 @@ import com.baidu.disconf.core.common.constants.Constants;
 import com.baidu.disconf.core.common.json.ValueVo;
 import com.baidu.disconf.core.common.restful.RestfulMgr;
 import com.baidu.disconf.core.common.restful.core.RemoteUrl;
-import com.github.knightliao.apollo.utils.io.OsUtil;
+import com.baidu.disconf.core.common.utils.OsUtil;
 
 /**
  * 抓取器, 独立模块,不依赖外部模块, 由Factory来管理此实例

+ 1 - 1
disconf-client/src/main/java/com/baidu/disconf/client/store/processor/impl/DisconfStoreFileProcessorImpl.java

@@ -20,7 +20,7 @@ import com.baidu.disconf.client.common.model.DisconfCenterFile.FileItemValue;
 import com.baidu.disconf.client.common.update.IDisconfUpdate;
 import com.baidu.disconf.client.store.DisconfStoreProcessor;
 import com.baidu.disconf.client.store.processor.model.DisconfValue;
-import com.github.knightliao.apollo.utils.common.ClassUtils;
+import com.baidu.disconf.client.utils.ClassUtils;
 
 /**
  * 配置文件仓库实现器

+ 3 - 3
disconf-client/src/main/java/com/baidu/disconf/client/store/processor/impl/DisconfStoreItemProcessorImpl.java

@@ -16,7 +16,7 @@ import com.baidu.disconf.client.common.update.IDisconfUpdate;
 import com.baidu.disconf.client.store.DisconfStoreProcessor;
 import com.baidu.disconf.client.store.inner.DisconfCenterStore;
 import com.baidu.disconf.client.store.processor.model.DisconfValue;
-import com.github.knightliao.apollo.utils.common.ClassUtils;
+import com.baidu.disconf.client.utils.ClassUtils;
 
 /**
  * 配置项仓库算子实现器
@@ -37,7 +37,7 @@ public class DisconfStoreItemProcessorImpl implements DisconfStoreProcessor {
         if (DisconfCenterStore.getInstance().getConfItemMap().containsKey(keyName)) {
 
             DisconfCenterStore.getInstance().getConfItemMap().get(keyName).getDisconfCommonCallbackModel()
-                .getDisconfConfUpdates().addAll(iDisconfUpdateList);
+                    .getDisconfConfUpdates().addAll(iDisconfUpdateList);
         }
 
     }
@@ -51,7 +51,7 @@ public class DisconfStoreItemProcessorImpl implements DisconfStoreProcessor {
         if (DisconfCenterStore.getInstance().getConfItemMap().containsKey(keyName)) {
 
             return DisconfCenterStore.getInstance().getConfItemMap().get(keyName).getDisconfCommonCallbackModel()
-                       .getDisconfConfUpdates();
+                    .getDisconfConfUpdates();
         }
 
         return new ArrayList<IDisconfUpdate>();

+ 3 - 3
disconf-client/src/main/java/com/baidu/disconf/client/utils/DisconfAutowareConfig.java → disconf-client/src/main/java/com/baidu/disconf/client/support/DisconfAutowareConfig.java

@@ -1,4 +1,4 @@
-package com.baidu.disconf.client.utils;
+package com.baidu.disconf.client.support;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
@@ -10,8 +10,8 @@ import org.slf4j.LoggerFactory;
 
 import com.baidu.disconf.client.common.annotations.DisconfFileItem;
 import com.baidu.disconf.client.config.inner.DisInnerConfigAnnotation;
-import com.github.knightliao.apollo.utils.common.ClassUtils;
-import com.github.knightliao.apollo.utils.config.ConfigLoaderUtils;
+import com.baidu.disconf.client.utils.ClassUtils;
+import com.baidu.disconf.client.utils.ConfigLoaderUtils;
 
 /**
  * 配置导入工具

+ 1 - 1
disconf-client/src/main/java/com/baidu/disconf/client/utils/EmailConstants.java → disconf-client/src/main/java/com/baidu/disconf/client/support/EmailConstants.java

@@ -1,4 +1,4 @@
-package com.baidu.disconf.client.utils;
+package com.baidu.disconf.client.support;
 
 /**
  * @author liaoqiqi

+ 192 - 0
disconf-client/src/main/java/com/baidu/disconf/client/utils/ClassUtils.java

@@ -0,0 +1,192 @@
+package com.baidu.disconf.client.utils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * 类工具
+ *
+ * @author liaoqiqi
+ * @version 2014-6-11
+ */
+public class ClassUtils {
+
+    /**
+     * 由Get Method名称获取Field名
+     *
+     * @return
+     */
+    public static String getFieldNameByGetMethodName(String methodName) {
+
+        int prefixIndex = 0;
+
+        // 必须以get或is开始的
+        if (methodName.startsWith("get")) {
+            prefixIndex = 3;
+
+        } else if (methodName.startsWith("is")) {
+
+            prefixIndex = 2;
+
+        } else {
+
+            return null;
+        }
+
+        String fieldName = methodName.substring(prefixIndex);
+        if (fieldName.length() >= 1) {
+            String firstCharStr = String.valueOf(fieldName.charAt(0))
+                    .toLowerCase();
+            if (fieldName.length() > 1) {
+                fieldName = firstCharStr + fieldName.substring(1);
+            } else {
+                fieldName = firstCharStr.toLowerCase();
+            }
+        }
+
+        return fieldName;
+    }
+
+    /**
+     * 根据Field类型设置值
+     *
+     * @param field
+     */
+    public static void setFieldValeByType(Field field, Object obj, String value)
+            throws Exception {
+
+        Class<?> type = field.getType();
+
+        String typeName = type.getName();
+
+        if (typeName.equals("int")) {
+
+            if (value.equals("")) {
+                value = "0";
+            }
+            field.set(obj, Integer.valueOf(value));
+
+        } else if (typeName.equals("long")) {
+
+            if (value.equals("")) {
+                value = "0";
+            }
+            field.set(obj, Long.valueOf(value));
+
+        } else if (typeName.equals("boolean")) {
+
+            if (value.equals("")) {
+                value = "false";
+            }
+            field.set(obj, Boolean.valueOf(value));
+
+        } else if (typeName.equals("double")) {
+
+            if (value.equals("")) {
+                value = "0.0";
+            }
+            field.set(obj, Double.valueOf(value));
+
+        } else {
+
+            field.set(obj, value);
+        }
+    }
+
+    /**
+     * 根据Field类型返回值
+     *
+     * @param type
+     * @param value
+     *
+     * @return
+     *
+     * @throws Exception
+     */
+    public static Object getValeByType(Class<?> type, Object value)
+            throws Exception {
+
+        // 预处理
+        if (!(value instanceof String)) {
+            value = "";
+        }
+
+        // trim
+        String dataValue = (String) value;
+        dataValue = dataValue.trim();
+
+        // process
+        String typeName = type.getName();
+        typeName = typeName.toLowerCase();
+
+        if (typeName.equals("int") || typeName.equals("java.lang.integer")) {
+
+            if (value.equals("")) {
+                value = "0";
+            }
+
+            return Integer.valueOf(dataValue);
+
+        } else if (typeName.equals("long") || typeName.equals("java.lang.long")) {
+
+            if (value.equals("")) {
+                value = "0";
+            }
+
+            return Long.valueOf(dataValue);
+
+        } else if (typeName.equals("boolean")
+                || typeName.equals("java.lang.boolean")) {
+
+            if (value.equals("")) {
+                value = "false";
+            }
+
+            return Boolean.valueOf(dataValue);
+
+        } else if (typeName.equals("double")
+                || typeName.equals("java.lang.double")) {
+
+            if (value.equals("")) {
+                value = "0.0";
+            }
+
+            return Double.valueOf(dataValue);
+
+        } else {
+
+            return value;
+        }
+    }
+
+    /**
+     * 获取一个类的所有方法
+     *
+     * @param entityClass
+     *
+     * @return
+     */
+    public static Set<Method> getAllMethod(Class<?> entityClass) {
+
+        // 获取本类的所有的方法
+        Set<Method> ms = new HashSet<Method>();
+        for (Method m : entityClass.getMethods()) {
+            ms.add(m);
+        }
+        for (Method m : entityClass.getDeclaredMethods()) {
+            ms.add(m);
+        }
+
+        // 递归获取父类的所有方法
+        Class<?> superClass = entityClass.getSuperclass();
+        if (!superClass.equals(Object.class)) {
+            Set<Method> superFields = getAllMethod(superClass);
+            ms.addAll(superFields);
+        }
+
+        return ms;
+    }
+
+}

+ 154 - 0
disconf-client/src/main/java/com/baidu/disconf/client/utils/ConfigLoaderUtils.java

@@ -0,0 +1,154 @@
+package com.baidu.disconf.client.utils;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.baidu.disconf.core.common.utils.ClassLoaderUtil;
+
+/**
+ * 配置导入工具
+ *
+ * @author liaoqiqi
+ * @version 2014-6-6
+ */
+public final class ConfigLoaderUtils {
+
+    protected static final Logger LOGGER = LoggerFactory
+            .getLogger(ConfigLoaderUtils.class);
+
+    private ConfigLoaderUtils() {
+
+    }
+
+    /**
+     * @param propertyFilePath
+     *
+     * @return void
+     *
+     * @Description: 使用TOMCAT方式来导入
+     * @author liaoqiqi
+     * @date 2013-6-19
+     */
+    private static Properties loadWithTomcatMode(final String propertyFilePath)
+            throws Exception {
+
+        Properties props = new Properties();
+
+        try {
+
+            // 先用TOMCAT模式进行导入
+            // http://blog.csdn.net/minfree/article/details/1800311
+            // http://stackoverflow.com/questions/3263560/sysloader-getresource-problem-in-java
+            URL url = ClassLoaderUtil.getLoader().getResource(propertyFilePath);
+            URI uri = new URI(url.toString());
+            props.load(new FileInputStream(uri.getPath()));
+
+        } catch (Exception e) {
+
+            // http://stackoverflow.com/questions/574809/load-a-resource-contained-in-a-jar
+            props.load(ClassLoaderUtil.getLoader().getResourceAsStream(propertyFilePath));
+        }
+        return props;
+    }
+
+    /**
+     * @param propertyFilePath
+     *
+     * @return void
+     *
+     * @Description: 使用普通模式导入
+     * @author liaoqiqi
+     * @date 2013-6-19
+     */
+    private static Properties loadWithNormalMode(final String propertyFilePath)
+            throws Exception {
+
+        Properties props = new Properties();
+        props.load(new FileInputStream(propertyFilePath));
+        return props;
+    }
+
+    /**
+     * @param propertyFilePath
+     *
+     * @return Properties
+     *
+     * @throws Exception
+     * @Description: 配置文件载入器助手
+     * @author liaoqiqi
+     * @date 2013-6-19
+     */
+    public static Properties loadConfig(final String propertyFilePath)
+            throws Exception {
+
+        try {
+
+            // 用TOMCAT模式 来载入试试
+            return ConfigLoaderUtils.loadWithTomcatMode(propertyFilePath);
+
+        } catch (Exception e1) {
+
+            try {
+                // 用普通模式进行载入
+                return loadWithNormalMode(propertyFilePath);
+
+            } catch (Exception e2) {
+
+                throw new Exception("cannot load config file: "
+                        + propertyFilePath);
+            }
+        }
+    }
+
+    /**
+     * @param filePath
+     *
+     * @return InputStream
+     *
+     * @Description: 采用两种方式来载入文件
+     * @author liaoqiqi
+     * @date 2013-6-20
+     */
+    public static InputStream loadFile(String filePath) {
+
+        InputStream in = null;
+
+        try {
+
+            // 先用TOMCAT模式进行导入
+            in = ClassLoaderUtil.getLoader().getResourceAsStream(filePath);
+            if (in == null) {
+
+                // 使用普通模式导入
+                try {
+
+                    return new FileInputStream(filePath);
+
+                } catch (FileNotFoundException e) {
+                    return null;
+                }
+            } else {
+
+                return in;
+            }
+
+        } finally {
+
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    LOGGER.error("WHY HERE!", e);
+                }
+            }
+        }
+    }
+}

+ 0 - 1
disconf-client/src/main/java/com/baidu/disconf/client/utils/MethodUtils.java

@@ -10,7 +10,6 @@ import org.slf4j.LoggerFactory;
 import com.baidu.disconf.client.common.annotations.DisconfFileItem;
 import com.baidu.disconf.client.common.annotations.DisconfItem;
 import com.baidu.disconf.core.common.constants.DisConfigTypeEnum;
-import com.github.knightliao.apollo.utils.common.ClassUtils;
 
 /**
  * @author liaoqiqi

+ 829 - 0
disconf-client/src/main/java/com/baidu/disconf/client/utils/StringUtil.java

@@ -0,0 +1,829 @@
+package com.baidu.disconf.client.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * 有关字符串处理的工具类。
+ * <p>
+ * 这个类中的每个方法都可以“安全”地处理<code>null</code>,而不会抛出<code>NullPointerException</code>。
+ * </p>
+ *
+ * @author liaoqiqi
+ * @version 2014-8-28
+ */
+public abstract class StringUtil {
+
+    private static final char[] DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+            .toCharArray();
+    private static final char[] DIGITS_NOCASE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+            .toCharArray();
+
+    /**
+     * @param source
+     * @param token
+     * @return
+     */
+    public static List<Integer> parseStringToIntegerList(String source,
+                                                         String token) {
+
+        if (StringUtils.isBlank(source) || StringUtils.isEmpty(token)) {
+            return null;
+        }
+
+        List<Integer> result = new ArrayList<Integer>();
+        String[] units = source.split(token);
+        for (String unit : units) {
+            result.add(Integer.valueOf(unit));
+        }
+
+        return result;
+    }
+
+    // ==========================================================================
+    // 默认值函数。
+    //
+    // 当字符串为empty或blank时,将字符串转换成指定的默认字符串。
+    // 注:判断字符串为null时,可用更通用的ObjectUtil.defaultIfNull。
+    // ==========================================================================
+
+    /**
+     * @param source
+     * @param token
+     * @return
+     */
+    public static List<Long> parseStringToLongList(String source, String token) {
+
+        if (StringUtils.isBlank(source) || StringUtils.isEmpty(token)) {
+            return null;
+        }
+
+        List<Long> result = new ArrayList<Long>();
+        String[] units = source.split(token);
+        for (String unit : units) {
+            result.add(Long.valueOf(unit));
+        }
+
+        return result;
+    }
+
+    /**
+     * @param source
+     * @param token
+     * @return
+     */
+    public static List<String> parseStringToStringList(String source,
+                                                       String token) {
+
+        if (StringUtils.isBlank(source) || StringUtils.isEmpty(token)) {
+            return null;
+        }
+
+        List<String> result = new ArrayList<String>();
+
+        String[] units = source.split(token);
+        for (String unit : units) {
+            result.add(unit);
+        }
+        return result;
+    }
+
+    // FIXME 待补
+
+    // ==========================================================================
+    // 格式替换。
+    // ==========================================================================
+
+    /**
+     * 如果字符串是<code>null</code>或空字符串<code>""</code>,则返回指定默认字符串,否则返回字符串本身。
+     * <p/>
+     * <p/>
+     * <pre>
+     * StringUtil.defaultIfEmpty(null, "default")  = "default"
+     * StringUtil.defaultIfEmpty("", "default")    = "default"
+     * StringUtil.defaultIfEmpty("  ", "default")  = "  "
+     * StringUtil.defaultIfEmpty("bat", "default") = "bat"
+     * </pre>
+     *
+     * @param str        要转换的字符串
+     * @param defaultStr 默认字符串
+     * @return 字符串本身或指定的默认字符串
+     */
+    public static String defaultIfEmpty(String str, String defaultStr) {
+        return str == null || str.length() == 0 ? defaultStr : str;
+    }
+
+    /**
+     * 如果字符串是<code>null</code>或空字符串<code>""</code>,则返回指定默认字符串,否则返回字符串本身。
+     * <p/>
+     * <p/>
+     * <pre>
+     * StringUtil.defaultIfBlank(null, "default")  = "default"
+     * StringUtil.defaultIfBlank("", "default")    = "default"
+     * StringUtil.defaultIfBlank("  ", "default")  = "default"
+     * StringUtil.defaultIfBlank("bat", "default") = "bat"
+     * </pre>
+     *
+     * @param str        要转换的字符串
+     * @param defaultStr 默认字符串
+     * @return 字符串本身或指定的默认字符串
+     */
+    public static String defaultIfBlank(String str, String defaultStr) {
+        return StringUtils.isBlank(str) ? defaultStr : str;
+    }
+
+    /**
+     * 将字符串转换成camel case。
+     * <p>
+     * 如果字符串是<code>null</code>则返回<code>null</code>。
+     * <p/>
+     * <p/>
+     * <pre>
+     * StringUtil.toCamelCase(null)  = null
+     * StringUtil.toCamelCase("")    = ""
+     * StringUtil.toCamelCase("aBc") = "aBc"
+     * StringUtil.toCamelCase("aBc def") = "aBcDef"
+     * StringUtil.toCamelCase("aBc def_ghi") = "aBcDefGhi"
+     * StringUtil.toCamelCase("aBc def_ghi 123") = "aBcDefGhi123"
+     * </pre>
+     * <p/>
+     * </p>
+     * <p>
+     * 此方法会保留除了下划线和空白以外的所有分隔符。
+     * </p>
+     *
+     * @param str 要转换的字符串
+     * @return camel case字符串,如果原字符串为<code>null</code>,则返回<code>null</code>
+     */
+    public static String toCamelCase(String str) {
+        return new WordTokenizer() {
+            @Override
+            protected void startSentence(StringBuilder buffer, char ch) {
+                buffer.append(Character.toLowerCase(ch));
+            }
+
+            @Override
+            protected void startWord(StringBuilder buffer, char ch) {
+                if (!isDelimiter(buffer.charAt(buffer.length() - 1))) {
+                    buffer.append(Character.toUpperCase(ch));
+                } else {
+                    buffer.append(Character.toLowerCase(ch));
+                }
+            }
+
+            @Override
+            protected void inWord(StringBuilder buffer, char ch) {
+                buffer.append(Character.toLowerCase(ch));
+            }
+
+            @Override
+            protected void startDigitSentence(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void startDigitWord(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void inDigitWord(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void inDelimiter(StringBuilder buffer, char ch) {
+                if (ch != UNDERSCORE) {
+                    buffer.append(ch);
+                }
+            }
+        }.parse(str);
+    }
+
+    /**
+     * 将字符串转换成pascal case。
+     * <p>
+     * 如果字符串是<code>null</code>则返回<code>null</code>。
+     * <p/>
+     * <p/>
+     * <pre>
+     * StringUtil.toPascalCase(null)  = null
+     * StringUtil.toPascalCase("")    = ""
+     * StringUtil.toPascalCase("aBc") = "ABc"
+     * StringUtil.toPascalCase("aBc def") = "ABcDef"
+     * StringUtil.toPascalCase("aBc def_ghi") = "ABcDefGhi"
+     * StringUtil.toPascalCase("aBc def_ghi 123") = "aBcDefGhi123"
+     * </pre>
+     * <p/>
+     * </p>
+     * <p>
+     * 此方法会保留除了下划线和空白以外的所有分隔符。
+     * </p>
+     *
+     * @param str 要转换的字符串
+     * @return pascal case字符串,如果原字符串为<code>null</code>,则返回<code>null</code>
+     */
+    public static String toPascalCase(String str) {
+        return new WordTokenizer() {
+            @Override
+            protected void startSentence(StringBuilder buffer, char ch) {
+                buffer.append(Character.toUpperCase(ch));
+            }
+
+            @Override
+            protected void startWord(StringBuilder buffer, char ch) {
+                buffer.append(Character.toUpperCase(ch));
+            }
+
+            @Override
+            protected void inWord(StringBuilder buffer, char ch) {
+                buffer.append(Character.toLowerCase(ch));
+            }
+
+            @Override
+            protected void startDigitSentence(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void startDigitWord(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void inDigitWord(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void inDelimiter(StringBuilder buffer, char ch) {
+                if (ch != UNDERSCORE) {
+                    buffer.append(ch);
+                }
+            }
+        }.parse(str);
+    }
+
+    /**
+     * 将字符串转换成下划线分隔的大写字符串。
+     * <p>
+     * 如果字符串是<code>null</code>则返回<code>null</code>。
+     * <p/>
+     * <p/>
+     * <pre>
+     * StringUtil.toUpperCaseWithUnderscores(null)  = null
+     * StringUtil.toUpperCaseWithUnderscores("")    = ""
+     * StringUtil.toUpperCaseWithUnderscores("aBc") = "A_BC"
+     * StringUtil.toUpperCaseWithUnderscores("aBc def") = "A_BC_DEF"
+     * StringUtil.toUpperCaseWithUnderscores("aBc def_ghi") = "A_BC_DEF_GHI"
+     * StringUtil.toUpperCaseWithUnderscores("aBc def_ghi 123") = "A_BC_DEF_GHI_123"
+     * StringUtil.toUpperCaseWithUnderscores("__a__Bc__") = "__A__BC__"
+     * </pre>
+     * <p/>
+     * </p>
+     * <p>
+     * 此方法会保留除了空白以外的所有分隔符。
+     * </p>
+     *
+     * @param str 要转换的字符串
+     * @return 下划线分隔的大写字符串,如果原字符串为<code>null</code>,则返回<code>null</code>
+     */
+    public static String toUpperCaseWithUnderscores(String str) {
+        return new WordTokenizer() {
+            @Override
+            protected void startSentence(StringBuilder buffer, char ch) {
+                buffer.append(Character.toUpperCase(ch));
+            }
+
+            @Override
+            protected void startWord(StringBuilder buffer, char ch) {
+                if (!isDelimiter(buffer.charAt(buffer.length() - 1))) {
+                    buffer.append(UNDERSCORE);
+                }
+
+                buffer.append(Character.toUpperCase(ch));
+            }
+
+            @Override
+            protected void inWord(StringBuilder buffer, char ch) {
+                buffer.append(Character.toUpperCase(ch));
+            }
+
+            @Override
+            protected void startDigitSentence(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void startDigitWord(StringBuilder buffer, char ch) {
+                if (!isDelimiter(buffer.charAt(buffer.length() - 1))) {
+                    buffer.append(UNDERSCORE);
+                }
+
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void inDigitWord(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void inDelimiter(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+        }.parse(str);
+    }
+
+    // ==========================================================================
+    // 将数字或字节转换成ASCII字符串的函数。
+    // ==========================================================================
+
+    /**
+     * 将字符串转换成下划线分隔的小写字符串。
+     * <p>
+     * 如果字符串是<code>null</code>则返回<code>null</code>。
+     * <p/>
+     * <p/>
+     * <pre>
+     * StringUtil.toLowerCaseWithUnderscores(null)  = null
+     * StringUtil.toLowerCaseWithUnderscores("")    = ""
+     * StringUtil.toLowerCaseWithUnderscores("aBc") = "a_bc"
+     * StringUtil.toLowerCaseWithUnderscores("aBc def") = "a_bc_def"
+     * StringUtil.toLowerCaseWithUnderscores("aBc def_ghi") = "a_bc_def_ghi"
+     * StringUtil.toLowerCaseWithUnderscores("aBc def_ghi 123") = "a_bc_def_ghi_123"
+     * StringUtil.toLowerCaseWithUnderscores("__a__Bc__") = "__a__bc__"
+     * </pre>
+     * <p/>
+     * </p>
+     * <p>
+     * 此方法会保留除了空白以外的所有分隔符。
+     * </p>
+     *
+     * @param str 要转换的字符串
+     * @return 下划线分隔的小写字符串,如果原字符串为<code>null</code>,则返回<code>null</code>
+     */
+    public static String toLowerCaseWithUnderscores(String str) {
+        return new WordTokenizer() {
+            @Override
+            protected void startSentence(StringBuilder buffer, char ch) {
+                buffer.append(Character.toLowerCase(ch));
+            }
+
+            @Override
+            protected void startWord(StringBuilder buffer, char ch) {
+                if (!isDelimiter(buffer.charAt(buffer.length() - 1))) {
+                    buffer.append(UNDERSCORE);
+                }
+
+                buffer.append(Character.toLowerCase(ch));
+            }
+
+            @Override
+            protected void inWord(StringBuilder buffer, char ch) {
+                buffer.append(Character.toLowerCase(ch));
+            }
+
+            @Override
+            protected void startDigitSentence(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void startDigitWord(StringBuilder buffer, char ch) {
+                if (!isDelimiter(buffer.charAt(buffer.length() - 1))) {
+                    buffer.append(UNDERSCORE);
+                }
+
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void inDigitWord(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+
+            @Override
+            protected void inDelimiter(StringBuilder buffer, char ch) {
+                buffer.append(ch);
+            }
+        }.parse(str);
+    }
+
+    /**
+     * 将一个长整形转换成62进制的字符串。
+     *
+     * @param longValue 64位数字
+     * @return 62进制的字符串
+     */
+    public static String longToString(long longValue) {
+        return longToString(longValue, false);
+    }
+
+    /**
+     * 将一个长整形转换成62进制的字符串。
+     *
+     * @param longValue 64位数字
+     * @param noCase    区分大小写
+     * @return 62进制的字符串
+     */
+    public static String longToString(long longValue, boolean noCase) {
+        char[] digits = noCase ? DIGITS_NOCASE : DIGITS;
+        int digitsLength = digits.length;
+
+        if (longValue == 0) {
+            return String.valueOf(digits[0]);
+        }
+
+        if (longValue < 0) {
+            longValue = -longValue;
+        }
+
+        StringBuilder strValue = new StringBuilder();
+
+        while (longValue != 0) {
+            int digit = (int) (longValue % digitsLength);
+            longValue = longValue / digitsLength;
+
+            strValue.append(digits[digit]);
+        }
+
+        return strValue.toString();
+    }
+
+    /**
+     * 将一个byte数组转换成62进制的字符串。
+     *
+     * @param bytes 二进制数组
+     * @return 62进制的字符串
+     */
+    public static String bytesToString(byte[] bytes) {
+        return bytesToString(bytes, false);
+    }
+
+    /**
+     * 将一个byte数组转换成62进制的字符串。
+     *
+     * @param bytes  二进制数组
+     * @param noCase 区分大小写
+     * @return 62进制的字符串
+     */
+    public static String bytesToString(byte[] bytes, boolean noCase) {
+        char[] digits = noCase ? DIGITS_NOCASE : DIGITS;
+        int digitsLength = digits.length;
+
+        if (ArrayUtils.isEmpty(bytes)) {
+            return String.valueOf(digits[0]);
+        }
+
+        StringBuilder strValue = new StringBuilder();
+        int value = 0;
+        int limit = Integer.MAX_VALUE >>> 8;
+        int i = 0;
+
+        do {
+            while (i < bytes.length && value < limit) {
+                value = (value << 8) + (0xFF & bytes[i++]);
+            }
+
+            while (value >= digitsLength) {
+                strValue.append(digits[value % digitsLength]);
+                value = value / digitsLength;
+            }
+        } while (i < bytes.length);
+
+        if (value != 0 || strValue.length() == 0) {
+            strValue.append(digits[value]);
+        }
+
+        return strValue.toString();
+    }
+
+    /**
+     * 判断字符串<code>str</code>是否以字符<code>ch</code>结尾
+     *
+     * @param str 要比较的字符串
+     * @param ch  结尾字符
+     * @return 如果字符串<code>str</code>是否以字符<code>ch</code>结尾,则返回<code>true</code>
+     */
+    public static boolean endsWithChar(String str, char ch) {
+        if (StringUtils.isEmpty(str)) {
+            return false;
+        }
+
+        return str.charAt(str.length() - 1) == ch;
+    }
+
+    // ==========================================================================
+    // 将字符串转化成集合
+    // ==========================================================================
+
+    // public static <T> List<T> toArrayList(String value) {
+    // if (value == null) {
+    // return null;
+    // }
+    // // FIXME "[ ...N个空格... ]"暂不考虑
+    // if (StringUtils.isBlank(value) || value.equals("[]")) {
+    // return Collections.emptyList();
+    // }
+    //
+    // // ", "
+    // value = StringUtils.substringBetween(value, "[", "]");
+    // String[] array = StringUtils.split(value, ", ");
+    // List<T>
+    //
+    // }
+
+    // ==========================================================================
+    // 字符串比较相关。
+    // ==========================================================================
+
+    /**
+     * 判断字符串<code>str</code>是否以字符<code>ch</code>开头
+     *
+     * @param str 要比较的字符串
+     * @param ch  开头字符
+     * @return 如果字符串<code>str</code>是否以字符<code>ch</code> 开头,则返回<code>true</code>
+     */
+    public static boolean startsWithChar(String str, char ch) {
+        if (StringUtils.isEmpty(str)) {
+            return false;
+        }
+
+        return str.charAt(0) == ch;
+    }
+
+    public static int indexOfChars(String string, String chars) {
+        return indexOfChars(string, chars, 0);
+    }
+
+    // ==========================================================================
+    // 字符串索引相关。
+    // ==========================================================================
+
+    public static int indexOfChars(String string, String chars, int startindex) {
+        if (string == null || chars == null) {
+            return -1;
+        }
+
+        int stringLen = string.length();
+        int charsLen = chars.length();
+
+        if (startindex < 0) {
+            startindex = 0;
+        }
+
+        for (int i = startindex; i < stringLen; i++) {
+            char c = string.charAt(i);
+            for (int j = 0; j < charsLen; j++) {
+                if (c == chars.charAt(j)) {
+                    return i;
+                }
+            }
+        }
+
+        return -1;
+    }
+
+    public static int indexOfChars(String string, char[] chars) {
+        return indexOfChars(string, chars, 0);
+    }
+
+    public static int indexOfChars(String string, char[] chars, int startindex) {
+        if (string == null || chars == null) {
+            return -1;
+        }
+
+        int stringLen = string.length();
+        int charsLen = chars.length;
+
+        for (int i = startindex; i < stringLen; i++) {
+            char c = string.charAt(i);
+            for (int j = 0; j < charsLen; j++) {
+                if (c == chars[j]) {
+                    return i;
+                }
+            }
+        }
+
+        return -1;
+    }
+
+    /**
+     * 解析出下列语法所构成的<code>SENTENCE</code>。
+     * <p/>
+     * <p/>
+     * <pre>
+     *  SENTENCE = WORD (DELIMITER* WORD)*
+     *
+     *  WORD = UPPER_CASE_WORD | LOWER_CASE_WORD | TITLE_CASE_WORD | DIGIT_WORD
+     *
+     *  UPPER_CASE_WORD = UPPER_CASE_LETTER+
+     *  LOWER_CASE_WORD = LOWER_CASE_LETTER+
+     *  TITLE_CASE_WORD = UPPER_CASE_LETTER LOWER_CASE_LETTER+
+     *  DIGIT_WORD      = DIGIT+
+     *
+     *  UPPER_CASE_LETTER = Character.isUpperCase()
+     *  LOWER_CASE_LETTER = Character.isLowerCase()
+     *  DIGIT             = Character.isDigit()
+     *  NON_LETTER_DIGIT  = !Character.isUpperCase() && !Character.isLowerCase() && !Character.isDigit()
+     *
+     *  DELIMITER = WHITESPACE | NON_LETTER_DIGIT
+     * </pre>
+     */
+    private abstract static class WordTokenizer {
+        protected static final char UNDERSCORE = '_';
+
+        /**
+         * Parse sentence。
+         */
+        public String parse(String str) {
+            if (StringUtils.isEmpty(str)) {
+                return str;
+            }
+
+            int length = str.length();
+            StringBuilder buffer = new StringBuilder(length);
+
+            for (int index = 0; index < length; index++) {
+                char ch = str.charAt(index);
+
+                // 忽略空白。
+                if (Character.isWhitespace(ch)) {
+                    continue;
+                }
+
+                // 大写字母开始:UpperCaseWord或是TitleCaseWord。
+                if (Character.isUpperCase(ch)) {
+                    int wordIndex = index + 1;
+
+                    while (wordIndex < length) {
+                        char wordChar = str.charAt(wordIndex);
+
+                        if (Character.isUpperCase(wordChar)) {
+                            wordIndex++;
+                        } else if (Character.isLowerCase(wordChar)) {
+                            wordIndex--;
+                            break;
+                        } else {
+                            break;
+                        }
+                    }
+
+                    // 1. wordIndex == length,说明最后一个字母为大写,以upperCaseWord处理之。
+                    // 2. wordIndex == index,说明index处为一个titleCaseWord。
+                    // 3. wordIndex > index,说明index到wordIndex -
+                    // 1处全部是大写,以upperCaseWord处理。
+                    if (wordIndex == length || wordIndex > index) {
+                        index = parseUpperCaseWord(buffer, str, index,
+                                wordIndex);
+                    } else {
+                        index = parseTitleCaseWord(buffer, str, index);
+                    }
+
+                    continue;
+                }
+
+                // 小写字母开始:LowerCaseWord。
+                if (Character.isLowerCase(ch)) {
+                    index = parseLowerCaseWord(buffer, str, index);
+                    continue;
+                }
+
+                // 数字开始:DigitWord。
+                if (Character.isDigit(ch)) {
+                    index = parseDigitWord(buffer, str, index);
+                    continue;
+                }
+
+                // 非字母数字开始:Delimiter。
+                inDelimiter(buffer, ch);
+            }
+
+            return buffer.toString();
+        }
+
+        private int parseUpperCaseWord(StringBuilder buffer, String str,
+                                       int index, int length) {
+            char ch = str.charAt(index++);
+
+            // 首字母,必然存在且为大写。
+            if (buffer.length() == 0) {
+                startSentence(buffer, ch);
+            } else {
+                startWord(buffer, ch);
+            }
+
+            // 后续字母,必为小写。
+            for (; index < length; index++) {
+                ch = str.charAt(index);
+                inWord(buffer, ch);
+            }
+
+            return index - 1;
+        }
+
+        private int parseLowerCaseWord(StringBuilder buffer, String str,
+                                       int index) {
+            char ch = str.charAt(index++);
+
+            // 首字母,必然存在且为小写。
+            if (buffer.length() == 0) {
+                startSentence(buffer, ch);
+            } else {
+                startWord(buffer, ch);
+            }
+
+            // 后续字母,必为小写。
+            int length = str.length();
+
+            for (; index < length; index++) {
+                ch = str.charAt(index);
+
+                if (Character.isLowerCase(ch)) {
+                    inWord(buffer, ch);
+                } else {
+                    break;
+                }
+            }
+
+            return index - 1;
+        }
+
+        private int parseTitleCaseWord(StringBuilder buffer, String str,
+                                       int index) {
+            char ch = str.charAt(index++);
+
+            // 首字母,必然存在且为大写。
+            if (buffer.length() == 0) {
+                startSentence(buffer, ch);
+            } else {
+                startWord(buffer, ch);
+            }
+
+            // 后续字母,必为小写。
+            int length = str.length();
+
+            for (; index < length; index++) {
+                ch = str.charAt(index);
+
+                if (Character.isLowerCase(ch)) {
+                    inWord(buffer, ch);
+                } else {
+                    break;
+                }
+            }
+
+            return index - 1;
+        }
+
+        private int parseDigitWord(StringBuilder buffer, String str, int index) {
+            char ch = str.charAt(index++);
+
+            // 首字符,必然存在且为数字。
+            if (buffer.length() == 0) {
+                startDigitSentence(buffer, ch);
+            } else {
+                startDigitWord(buffer, ch);
+            }
+
+            // 后续字符,必为数字。
+            int length = str.length();
+
+            for (; index < length; index++) {
+                ch = str.charAt(index);
+
+                if (Character.isDigit(ch)) {
+                    inDigitWord(buffer, ch);
+                } else {
+                    break;
+                }
+            }
+
+            return index - 1;
+        }
+
+        protected boolean isDelimiter(char ch) {
+            return !Character.isUpperCase(ch) && !Character.isLowerCase(ch)
+                    && !Character.isDigit(ch);
+        }
+
+        protected abstract void startSentence(StringBuilder buffer, char ch);
+
+        protected abstract void startWord(StringBuilder buffer, char ch);
+
+        protected abstract void inWord(StringBuilder buffer, char ch);
+
+        protected abstract void startDigitSentence(StringBuilder buffer, char ch);
+
+        protected abstract void startDigitWord(StringBuilder buffer, char ch);
+
+        protected abstract void inDigitWord(StringBuilder buffer, char ch);
+
+        protected abstract void inDelimiter(StringBuilder buffer, char ch);
+    }
+
+}

+ 5 - 5
disconf-client/src/main/java/com/baidu/disconf/client/watch/impl/WatchMgrImpl.java

@@ -12,8 +12,8 @@ import com.baidu.disconf.client.watch.inner.DisconfSysUpdateCallback;
 import com.baidu.disconf.client.watch.inner.NodeWatcher;
 import com.baidu.disconf.core.common.constants.DisConfigTypeEnum;
 import com.baidu.disconf.core.common.path.ZooPathMgr;
+import com.baidu.disconf.core.common.utils.ZooUtils;
 import com.baidu.disconf.core.common.zookeeper.ZookeeperMgr;
-import com.github.knightliao.apollo.utils.tool.ZooUtils;
 
 /**
  * Watch 模块的一个实现
@@ -60,8 +60,8 @@ public class WatchMgrImpl implements WatchMgr {
             应用程序的 Zoo 根目录
         */
         String clientRootZooPath = ZooPathMgr.getZooBaseUrl(zooUrlPrefix, disConfCommonModel.getApp(),
-                                                               disConfCommonModel.getEnv(),
-                                                               disConfCommonModel.getVersion());
+                disConfCommonModel.getEnv(),
+                disConfCommonModel.getVersion());
         ZookeeperMgr.getInstance().makeDir(clientRootZooPath, ZooUtils.getIp());
 
         // 监控路径
@@ -125,8 +125,8 @@ public class WatchMgrImpl implements WatchMgr {
 
         // 进行监控
         NodeWatcher nodeWatcher =
-            new NodeWatcher(disconfCoreMgr, monitorPath, keyName, disConfigTypeEnum, new DisconfSysUpdateCallback(),
-                               debug);
+                new NodeWatcher(disconfCoreMgr, monitorPath, keyName, disConfigTypeEnum, new DisconfSysUpdateCallback(),
+                        debug);
         nodeWatcher.monitorMaster();
     }
 

+ 2 - 2
disconf-client/src/test/java/com/baidu/disconf/client/test/DisconfMgrTestCase.java

@@ -24,8 +24,8 @@ import com.baidu.disconf.client.test.model.ServiceA;
 import com.baidu.disconf.client.test.model.StaticConf;
 import com.baidu.disconf.client.test.scan.inner.ScanPackTestCase;
 import com.baidu.disconf.client.test.watch.mock.WatchMgrMock;
+import com.baidu.disconf.client.utils.StringUtil;
 import com.baidu.disconf.client.watch.WatchMgr;
-import com.github.knightliao.apollo.utils.common.StringUtil;
 
 import mockit.Mock;
 import mockit.MockUp;
@@ -91,7 +91,7 @@ public class DisconfMgrTestCase extends BaseSpringMockTestCase {
             fileSet.add("atomserverm_slave.properties");
             DisconfCenterHostFilesStore.getInstance().addJustHostFileSet(fileSet);
             DisconfMgr.start(StringUtil.parseStringToStringList(ScanPackTestCase.SCAN_PACK_NAME,
-                                                                   DisconfMgrBean.SCAN_SPLIT_TOKEN));
+                    DisconfMgrBean.SCAN_SPLIT_TOKEN));
 
             //
             LOGGER.info(DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().confToString());

+ 4 - 4
disconf-client/src/test/java/com/baidu/disconf/client/test/common/BaseSpringMockTestCase.java

@@ -10,9 +10,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import com.baidu.disconf.client.config.ConfigMgr;
 import com.baidu.disconf.client.config.DisClientConfig;
 import com.baidu.disconf.client.config.DisClientSysConfig;
+import com.baidu.disconf.client.test.utils.NetUtils;
 import com.baidu.disconf.core.common.path.DisconfWebPathMgr;
 import com.baidu.disconf.core.test.common.BaseCoreTestCase;
-import com.github.knightliao.apollo.utils.web.NetUtils;
 
 import junit.framework.Assert;
 
@@ -49,9 +49,9 @@ public class BaseSpringMockTestCase extends BaseCoreTestCase {
         }
 
         if (!NetUtils.pingUrl(DisClientConfig.getInstance().getHostList().get(0) + DisconfWebPathMgr
-                                                                                       .getZooHostsUrl
-                                                                                            (DisClientSysConfig
-                                                                                                           .getInstance().CONF_SERVER_ZOO_ACTION))) {
+                .getZooHostsUrl
+                        (DisClientSysConfig
+                                .getInstance().CONF_SERVER_ZOO_ACTION))) {
             return false;
         }
 

+ 4 - 4
disconf-client/src/test/java/com/baidu/disconf/client/test/common/BaseSpringTestCase.java

@@ -10,8 +10,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import com.baidu.disconf.client.config.ConfigMgr;
 import com.baidu.disconf.client.config.DisClientConfig;
 import com.baidu.disconf.client.config.DisClientSysConfig;
+import com.baidu.disconf.client.test.utils.NetUtils;
 import com.baidu.disconf.core.common.path.DisconfWebPathMgr;
-import com.github.knightliao.apollo.utils.web.NetUtils;
 
 import junit.framework.Assert;
 
@@ -48,9 +48,9 @@ public class BaseSpringTestCase {
         }
 
         if (!NetUtils.pingUrl(DisClientConfig.getInstance().getHostList().get(0) + DisconfWebPathMgr
-                                                                                       .getZooHostsUrl
-                                                                                            (DisClientSysConfig
-                                                                                                           .getInstance().CONF_SERVER_ZOO_ACTION))) {
+                .getZooHostsUrl
+                        (DisClientSysConfig
+                                .getInstance().CONF_SERVER_ZOO_ACTION))) {
             return false;
         }
 

+ 2 - 2
disconf-client/src/test/java/com/baidu/disconf/client/test/scan/inner/ScanPackTestCase.java

@@ -16,7 +16,7 @@ import com.baidu.disconf.client.scan.inner.statically.strategy.ScanStaticStrateg
 import com.baidu.disconf.client.scan.inner.statically.strategy.impl.ReflectionScanStatic;
 import com.baidu.disconf.client.test.common.BaseSpringTestCase;
 import com.baidu.disconf.client.utils.ScanPrinterUtils;
-import com.github.knightliao.apollo.utils.common.StringUtil;
+import com.baidu.disconf.client.utils.StringUtil;
 
 /**
  * 扫描测试
@@ -30,7 +30,7 @@ public class ScanPackTestCase extends BaseSpringTestCase {
 
     public static final String SCAN_PACK_NAME = "com.baidu.disconf.client.test";
     public static final List<String> SCAN_PACK_NAME_LIST =
-        StringUtil.parseStringToStringList(SCAN_PACK_NAME, DisconfMgrBean.SCAN_SPLIT_TOKEN);
+            StringUtil.parseStringToStringList(SCAN_PACK_NAME, DisconfMgrBean.SCAN_SPLIT_TOKEN);
 
     @Test
     public void scan() {

+ 62 - 0
disconf-client/src/test/java/com/baidu/disconf/client/test/utils/NetUtils.java

@@ -0,0 +1,62 @@
+package com.baidu.disconf.client.test.utils;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 网络工具
+ *
+ * @author liaoqiqi
+ * @version 2014-6-17
+ */
+public final class NetUtils {
+
+    protected static final Logger LOGGER = LoggerFactory
+            .getLogger(NetUtils.class);
+
+    private NetUtils() {
+
+    }
+
+    /**
+     * PING指定URL是否可用
+     *
+     * @param address
+     * @return
+     */
+    public static boolean pingUrl(final String address) {
+
+        try {
+
+            final URL url = new URL("http://" + address);
+
+            final HttpURLConnection urlConn = (HttpURLConnection) url
+                    .openConnection();
+
+            urlConn.setConnectTimeout(1000 * 10); // mTimeout is in seconds
+
+            final long startTime = System.currentTimeMillis();
+
+            urlConn.connect();
+
+            final long endTime = System.currentTimeMillis();
+
+            if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
+                LOGGER.info("Time (ms) : " + (endTime - startTime));
+                LOGGER.info("Ping to " + address + " was success");
+                return true;
+            }
+
+        } catch (final MalformedURLException e1) {
+            e1.printStackTrace();
+        } catch (final IOException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+}

+ 0 - 8
disconf-core/pom.xml

@@ -27,13 +27,6 @@
 
     <dependencies>
 
-        <!-- my dependencies -->
-
-        <dependency>
-            <groupId>com.github.knightliao.apollo</groupId>
-            <artifactId>apollo</artifactId>
-        </dependency>
-
         <!-- common dependencies -->
 
         <dependency>
@@ -56,7 +49,6 @@
         <dependency>
             <groupId>com.google.code.gson</groupId>
             <artifactId>gson</artifactId>
-            <scope>test</scope>
         </dependency>
 
         <dependency>

+ 2 - 2
disconf-core/src/main/java/com/baidu/disconf/core/common/restful/impl/RestfulMgrImpl.java

@@ -20,9 +20,9 @@ import com.baidu.disconf.core.common.restful.core.UnreliableInterface;
 import com.baidu.disconf.core.common.restful.retry.RetryStrategy;
 import com.baidu.disconf.core.common.restful.type.FetchConfFile;
 import com.baidu.disconf.core.common.restful.type.RestfulGet;
+import com.baidu.disconf.core.common.utils.ClassLoaderUtil;
 import com.baidu.disconf.core.common.utils.MyStringUtils;
-import com.github.knightliao.apollo.utils.io.OsUtil;
-import com.github.knightliao.apollo.utils.tool.ClassLoaderUtil;
+import com.baidu.disconf.core.common.utils.OsUtil;
 
 /**
  * RestFul的一个实现, 独立模块

+ 1 - 1
disconf-core/src/main/java/com/baidu/disconf/core/common/restful/type/FetchConfFile.java

@@ -8,7 +8,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.baidu.disconf.core.common.restful.core.UnreliableInterface;
-import com.github.knightliao.apollo.utils.io.OsUtil;
+import com.baidu.disconf.core.common.utils.OsUtil;
 
 /**
  * 下载文件

+ 67 - 0
disconf-core/src/main/java/com/baidu/disconf/core/common/utils/ClassLoaderUtil.java

@@ -0,0 +1,67 @@
+package com.baidu.disconf.core.common.utils;
+
+import java.net.URLDecoder;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public final class ClassLoaderUtil {
+
+    protected static final Logger LOGGER = LoggerFactory
+            .getLogger(ClassLoaderUtil.class);
+
+    // class path
+    private static String classPath = "";
+
+    // loader
+    private static ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+    /*
+
+     */
+    private ClassLoaderUtil() {
+
+    }
+
+    //
+    // get class path
+    //
+    static {
+
+        if (loader == null) {
+            LOGGER.info("using system class loader!");
+            loader = ClassLoader.getSystemClassLoader();
+        }
+
+        try {
+
+            java.net.URL url = loader.getResource("");
+            // get class path
+            classPath = url.getPath();
+            classPath = URLDecoder.decode(classPath, "utf-8");
+
+            // 如果是jar包内的,则返回当前路径
+            if (classPath.contains(".jar!")) {
+                LOGGER.warn("using config file inline jar!");
+                classPath = System.getProperty("user.dir");
+            }
+
+        } catch (Exception e) {
+            LOGGER.warn("cannot get classpath using getResource(), now using user.dir");
+            classPath = System.getProperty("user.dir");
+        }
+
+        LOGGER.info("classpath: {}", classPath);
+    }
+
+    public static String getClassPath() {
+        return classPath;
+    }
+
+    public static ClassLoader getLoader() {
+        return loader;
+    }
+}

+ 120 - 0
disconf-core/src/main/java/com/baidu/disconf/core/common/utils/FileUtils.java

@@ -0,0 +1,120 @@
+package com.baidu.disconf.core.common.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 文件操作的方法集
+ *
+ * @author liaoqiqi
+ * @version 2014-8-20
+ */
+public final class FileUtils extends org.apache.commons.io.FileUtils {
+
+    private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
+
+    private FileUtils() {
+
+    }
+
+    /**
+     * 关闭文件流
+     *
+     * @param w 上午10:27:27 created by Darwin(Tianxin)
+     */
+    public final static void closeWriter(Writer w) {
+        if (w != null) {
+            try {
+                w.close();
+            } catch (Exception e) {
+            }
+        }
+    }
+
+    /**
+     * 关闭文件流
+     *
+     * @param r 上午10:27:27 created by Darwin(Tianxin)
+     */
+    public final static void closeReader(Reader r) {
+        if (r != null) {
+            try {
+                r.close();
+            } catch (Exception e) {
+            }
+        }
+    }
+
+    /**
+     * 关闭文件流
+     *
+     * @param os 上午10:27:27 created by Darwin(Tianxin)
+     */
+    public final static void closeOutputStream(OutputStream os) {
+        if (os != null) {
+            try {
+                os.close();
+            } catch (Exception e) {
+            }
+        }
+    }
+
+    /**
+     * 关闭文件流
+     *
+     * @param is 上午10:27:27 created by Darwin(Tianxin)
+     */
+    public final static void closeInputStream(InputStream is) {
+        if (is != null) {
+            try {
+                is.close();
+            } catch (Exception e) {
+            }
+        }
+    }
+
+    /**
+     * 使用jar包:commons-codec-1.4.jar的md5比较方法 <br/>
+     * http://blog.csdn.net/very365_1208/article/details/8824033
+     *
+     * @param oldName
+     * @param newName
+     *
+     * @return
+     */
+    public static boolean isFileUpdate(String oldName, String newName) {
+
+        return isFileEqual(new File(oldName), new File(newName));
+    }
+
+    /**
+     * http://blog.csdn.net/very365_1208/article/details/8824033
+     * http://www.avajava.com/tutorials/lessons/whats-a-quick-way
+     * -to-tell-if-the-contents-of-two-files-are-identical-or-not.html
+     *
+     * @param oldFile
+     * @param newFile
+     *
+     * @return
+     */
+    public static boolean isFileEqual(File oldFile, File newFile) {
+
+        try {
+
+            return contentEquals(oldFile, newFile);
+
+        } catch (IOException e) {
+
+            logger.warn(e.toString());
+            return false;
+        }
+
+    }
+}

+ 48 - 0
disconf-core/src/main/java/com/baidu/disconf/core/common/utils/GsonUtils.java

@@ -0,0 +1,48 @@
+package com.baidu.disconf.core.common.utils;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+/**
+ * Google Json工具
+ *
+ * @author liaoqiqi
+ * @version 2014-6-16
+ */
+public final class GsonUtils {
+
+    private GsonUtils() {
+
+    }
+
+    /**
+     * @param object
+     * @return
+     */
+    public static String toJson(Object object) {
+
+        Gson gson = new Gson();
+        String json = gson.toJson(object);
+        return json;
+    }
+
+    /**
+     * Parse json to map
+     *
+     * @param json
+     * @return
+     */
+    public static Map<String, String> parse2Map(String json) {
+
+        Type stringStringMap = new TypeToken<Map<String, String>>() {
+        }.getType();
+
+        Gson gson = new Gson();
+        Map<String, String> map = gson.fromJson(json, stringStringMap);
+
+        return map;
+    }
+}

+ 54 - 0
disconf-core/src/main/java/com/baidu/disconf/core/common/utils/MachineInfo.java

@@ -0,0 +1,54 @@
+package com.baidu.disconf.core.common.utils;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * @author liaoqiqi
+ * @version 2014-7-30
+ */
+public final class MachineInfo {
+
+    private MachineInfo() {
+
+    }
+
+    /**
+     * @return
+     *
+     * @Description: 获取机器名
+     */
+    public static String getHostName() throws Exception {
+
+        try {
+            InetAddress addr = InetAddress.getLocalHost();
+            String hostname = addr.getHostName();
+
+            return hostname;
+
+        } catch (UnknownHostException e) {
+
+            throw new Exception();
+        }
+    }
+
+    /**
+     * @return
+     *
+     * @Description: 获取机器名
+     */
+    public static String getHostIp() throws Exception {
+
+        try {
+            InetAddress addr = InetAddress.getLocalHost();
+            String ip = addr.getHostAddress();
+
+            return ip;
+
+        } catch (UnknownHostException e) {
+
+            throw new Exception();
+        }
+    }
+
+}

+ 224 - 0
disconf-core/src/main/java/com/baidu/disconf/core/common/utils/OsUtil.java

@@ -0,0 +1,224 @@
+package com.baidu.disconf.core.common.utils;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author knightliao
+ */
+public final class OsUtil {
+
+    private static final Logger logger = LoggerFactory.getLogger(OsUtil.class);
+
+    private OsUtil() {
+
+    }
+
+    /**
+     * 建多层目录
+     *
+     * @param filePath
+     *
+     * @return boolean
+     *
+     * @throws
+     * @Description: make directory
+     */
+    public static boolean makeDirs(final String filePath) {
+        File f = new File(filePath);
+        if (!f.exists()) {
+            return f.mkdirs();
+        }
+
+        return true;
+    }
+
+    /**
+     * @param filePathString
+     *
+     * @return boolean
+     *
+     * @throws Exception
+     * @Description: 文件或目录是否存在
+     * @author liaoqiqi
+     * @date 2013-6-13
+     */
+    public static boolean isFileExist(final String filePathString) throws Exception {
+
+        File f = new File(filePathString);
+        return f.exists();
+    }
+
+    /**
+     * @param pathElements
+     *
+     * @return boolean
+     *
+     * @throws Exception
+     * @Description: JOIN PATH
+     * @author liaoqiqi
+     * @date 2013-6-13
+     */
+    public static String pathJoin(final String... pathElements) {
+
+        final String path;
+
+        if (pathElements == null || pathElements.length == 0) {
+            path = File.separator;
+
+        } else {
+
+            final StringBuffer sb = new StringBuffer();
+
+            for (final String pathElement : pathElements) {
+
+                if (pathElement.length() > 0) {
+                    sb.append(pathElement);
+                    sb.append(File.separator);
+                }
+            }
+
+            if (sb.length() > 0) {
+                sb.deleteCharAt(sb.length() - 1);
+            }
+
+            path = sb.toString();
+        }
+
+        return (path);
+    }
+
+    /**
+     * 获取File相对于Folder的相对路径
+     * <p/>
+     * returns null if file isn't relative to folder
+     */
+    public static String getRelativePath(File file, File folder) {
+
+        String filePath = file.getAbsolutePath();
+        String folderPath = folder.getAbsolutePath();
+
+        if (filePath.startsWith(folderPath)) {
+            return filePath.substring(folderPath.length() + 1);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * @param src
+     * @param dest
+     *
+     * @return void
+     *
+     * @Description: 转移文件
+     * @author liaoqiqi
+     * @date 2013-6-20
+     */
+    public static void transferFile(File src, File dest) throws Exception {
+
+        // 删除文件
+        // LOGGER.info("start to remove download file: " + ""
+        // + dest.getAbsolutePath());
+        if (dest.exists()) {
+            dest.delete();
+        }
+
+        // 转移临时下载文件至下载文件夹
+        FileUtils.copyFile(src, dest);
+    }
+
+    /**
+     * @param src
+     * @param dest
+     *
+     * @return void
+     *
+     * @Description: 具有重试机制的 ATOM 转移文件 ,并且会校验文件是否一致 才替换
+     * @author liaoqiqi
+     * @date 2013-6-20
+     */
+    public static void transferFileAtom(File src, File dest, boolean isDeleteSource) throws Exception {
+
+        // 文件锁所在文件
+        File lockFile = new File(dest + ".lock");
+        FileOutputStream outStream = null;
+        FileLock lock = null;
+
+        try {
+            outStream = new FileOutputStream(lockFile);
+            FileChannel channel = outStream.getChannel();
+            try {
+
+                int tryTime = 0;
+                while (tryTime < 3) {
+
+                    lock = channel.tryLock();
+                    if (lock != null) {
+
+                        if (dest.exists()) {
+                            // 判断内容是否一样
+                            if (FileUtils.isFileEqual(src, dest)) {
+                                // 删除
+                                if (isDeleteSource) {
+                                    src.delete();
+                                }
+                                break;
+                            }
+                        }
+
+                        logger.debug("start to replace " + src.getAbsolutePath() + " to " + dest.getAbsolutePath());
+
+                        // 转移
+                        transferFile(src, dest);
+
+                        // 删除
+                        if (isDeleteSource) {
+                            src.delete();
+                        }
+
+                        break;
+                    }
+
+                    logger.warn("try lock failed. sleep and try " + tryTime);
+                    tryTime++;
+
+                    try {
+                        Thread.sleep(1000 * tryTime);
+                    } catch (Exception e) {
+                    }
+                }
+
+            } catch (IOException e) {
+                logger.warn(e.toString());
+            }
+
+        } catch (FileNotFoundException e) {
+            logger.warn(e.toString());
+
+        } finally {
+
+            if (null != lock) {
+                try {
+                    lock.release();
+                } catch (IOException e) {
+                    logger.warn(e.toString());
+                }
+            }
+            if (outStream != null) {
+                try {
+                    outStream.close();
+                } catch (IOException e) {
+                    logger.warn(e.toString());
+                }
+            }
+        }
+    }
+}

+ 34 - 0
disconf-core/src/main/java/com/baidu/disconf/core/common/utils/ZooUtils.java

@@ -0,0 +1,34 @@
+package com.baidu.disconf.core.common.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author liaoqiqi
+ * @version 2014-7-30
+ */
+public final class ZooUtils {
+
+    protected static final Logger LOGGER = LoggerFactory
+            .getLogger(ZooUtils.class);
+
+    private ZooUtils() {
+
+    }
+
+    /**
+     * 一个可读性良好的路径Value
+     *
+     * @return
+     */
+    public static String getIp() {
+
+        try {
+            return MachineInfo.getHostIp();
+        } catch (Exception e) {
+            LOGGER.error("cannot get host info", e);
+            return "";
+        }
+    }
+
+}

+ 2 - 2
disconf-core/src/main/java/com/baidu/disconf/core/common/zookeeper/ZookeeperMgr.java

@@ -11,8 +11,8 @@ import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.baidu.disconf.core.common.utils.ZooUtils;
 import com.baidu.disconf.core.common.zookeeper.inner.ResilientActiveKeyValueStore;
-import com.github.knightliao.apollo.utils.tool.ZooUtils;
 
 /**
  * ZK统一管理器
@@ -89,7 +89,7 @@ public class ZookeeperMgr {
      * @date 2013-6-14
      */
     private void initInternal(String hosts, String defaultPrefixString, boolean debug)
-        throws IOException, InterruptedException {
+            throws IOException, InterruptedException {
 
         curHost = hosts;
         curDefaultPrefixString = defaultPrefixString;

+ 1 - 1
disconf-core/src/test/java/com/baidu/disconf/core/test/TestSuite.java

@@ -7,7 +7,7 @@ import org.junit.runners.Suite.SuiteClasses;
 import com.baidu.disconf.core.test.path.DisconfWebPathMgrTestCase;
 import com.baidu.disconf.core.test.path.ZooPathMgrTestCase;
 import com.baidu.disconf.core.test.restful.RestfulMgrTestCase;
-import com.baidu.disconf.core.test.utiils.MyStringUtilsTestCase;
+import com.baidu.disconf.core.test.utils.MyStringUtilsTestCase;
 import com.baidu.disconf.core.test.zookeeper.ZookeeperMgrTest;
 
 /**

+ 29 - 29
disconf-core/src/test/java/com/baidu/disconf/core/test/common/BaseCoreTestCase.java

@@ -14,8 +14,8 @@ import org.slf4j.LoggerFactory;
 
 import com.baidu.disconf.core.common.constants.Constants;
 import com.baidu.disconf.core.common.json.ValueVo;
+import com.baidu.disconf.core.common.utils.GsonUtils;
 import com.baidu.disconf.core.test.restful.RemoteMockServer;
-import com.github.knightliao.apollo.utils.data.GsonUtils;
 import com.github.tomakehurst.wiremock.junit.WireMockClassRule;
 
 /**
@@ -56,55 +56,55 @@ public class BaseCoreTestCase {
         valueVo.setValue(RemoteMockServer.DEFAULT_ITEM_VALUE);
         // System.out.println(GsonUtils.toJson(valueVo));
         stubFor(get(urlEqualTo(RemoteMockServer.ITEM_URL))
-                    .willReturn(aResponse().withHeader("Content-Type", RemoteMockServer.CONTENT_TYPE).withStatus(200)
-                                    .withBody(GsonUtils.toJson(valueVo))));
+                .willReturn(aResponse().withHeader("Content-Type", RemoteMockServer.CONTENT_TYPE).withStatus(200)
+                        .withBody(GsonUtils.toJson(valueVo))));
 
         //
         // 配置文件
         //
         stubFor(get(urlEqualTo(RemoteMockServer.FILE_URL))
-                    .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
-                                    .withHeader("Content-Disposition",
-                                                   "attachment; filename=" + RemoteMockServer.FILE_NAME).withStatus(200)
-                                    .withBody(RemoteMockServer.FILE_CONTENT.getBytes())));
+                .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
+                        .withHeader("Content-Disposition",
+                                "attachment; filename=" + RemoteMockServer.FILE_NAME).withStatus(200)
+                        .withBody(RemoteMockServer.FILE_CONTENT.getBytes())));
 
         //
         // 空配置文件
         //
         stubFor(get(urlEqualTo(RemoteMockServer.EMPTY_FILE_URL))
-                    .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
-                                    .withHeader("Content-Disposition",
-                                                   "attachment; filename=" + RemoteMockServer.EMPTY_FILE_URL)
-                                    .withStatus(200).withBody(RemoteMockServer.FILE_CONTENT.getBytes())));
+                .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
+                        .withHeader("Content-Disposition",
+                                "attachment; filename=" + RemoteMockServer.EMPTY_FILE_URL)
+                        .withStatus(200).withBody(RemoteMockServer.FILE_CONTENT.getBytes())));
 
         //
         // 静态 配置文件
         //
         stubFor(get(urlEqualTo(RemoteMockServer.STATIC_FILE_URL))
-                    .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
-                                    .withHeader("Content-Disposition",
-                                                   "attachment; filename=" + RemoteMockServer.STATIC_FILE_NAME)
-                                    .withStatus(200).withBody(RemoteMockServer.STATIC_FILE_CONTENT.getBytes())));
+                .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
+                        .withHeader("Content-Disposition",
+                                "attachment; filename=" + RemoteMockServer.STATIC_FILE_NAME)
+                        .withStatus(200).withBody(RemoteMockServer.STATIC_FILE_CONTENT.getBytes())));
 
         //
         // 非注解 配置文件
         //
         stubFor(get(urlEqualTo(RemoteMockServer.NON_ANOTATION_FILE_URL))
-                    .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
-                                    .withHeader("Content-Disposition",
-                                                   "attachment; filename=" + RemoteMockServer.NON_ANOTATION_FILE_NAME)
-                                    .withStatus(200)
-                                    .withBody(RemoteMockServer.NON_ANOTATTION_FILE_CONTENT.getBytes())));
+                .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
+                        .withHeader("Content-Disposition",
+                                "attachment; filename=" + RemoteMockServer.NON_ANOTATION_FILE_NAME)
+                        .withStatus(200)
+                        .withBody(RemoteMockServer.NON_ANOTATTION_FILE_CONTENT.getBytes())));
 
         //
         // 非注解 配置文件2
         //
         stubFor(get(urlEqualTo(RemoteMockServer.NON_ANOTATION_FILE_URL2))
-                    .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
-                                    .withHeader("Content-Disposition",
-                                                   "attachment; filename=" + RemoteMockServer.NON_ANOTATION_FILE_NAME2)
-                                    .withStatus(200)
-                                    .withBody(RemoteMockServer.NON_ANOTATTION_FILE_CONTENT2.getBytes())));
+                .willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
+                        .withHeader("Content-Disposition",
+                                "attachment; filename=" + RemoteMockServer.NON_ANOTATION_FILE_NAME2)
+                        .withStatus(200)
+                        .withBody(RemoteMockServer.NON_ANOTATTION_FILE_CONTENT2.getBytes())));
 
         //
         // ZOO
@@ -115,8 +115,8 @@ public class BaseCoreTestCase {
         valueVo.setValue(RemoteMockServer.ZOO_HOSTS);
         // System.out.println(GsonUtils.toJson(valueVo));
         stubFor(get(urlEqualTo(RemoteMockServer.ZOO_URL))
-                    .willReturn(aResponse().withHeader("Content-Type", RemoteMockServer.CONTENT_TYPE).withStatus(200)
-                                    .withBody(GsonUtils.toJson(valueVo))));
+                .willReturn(aResponse().withHeader("Content-Type", RemoteMockServer.CONTENT_TYPE).withStatus(200)
+                        .withBody(GsonUtils.toJson(valueVo))));
 
         valueVo = new ValueVo();
         valueVo.setMessage("");
@@ -124,8 +124,8 @@ public class BaseCoreTestCase {
         valueVo.setValue(RemoteMockServer.ZOO_PREFIX_VALUE);
         // System.out.println(GsonUtils.toJson(valueVo));
         stubFor(get(urlEqualTo(RemoteMockServer.ZOO_PREFIX_URL))
-                    .willReturn(aResponse().withHeader("Content-Type", RemoteMockServer.CONTENT_TYPE).withStatus(200)
-                                    .withBody(GsonUtils.toJson(valueVo))));
+                .willReturn(aResponse().withHeader("Content-Type", RemoteMockServer.CONTENT_TYPE).withStatus(200)
+                        .withBody(GsonUtils.toJson(valueVo))));
 
     }
 

+ 1 - 1
disconf-core/src/test/java/com/baidu/disconf/core/test/utiils/MyStringUtilsTestCase.java → disconf-core/src/test/java/com/baidu/disconf/core/test/utils/MyStringUtilsTestCase.java

@@ -1,4 +1,4 @@
-package com.baidu.disconf.core.test.utiils;
+package com.baidu.disconf.core.test.utils;
 
 import org.junit.Test;
 

+ 0 - 7
disconf-tool/README.md

@@ -1,7 +0,0 @@
-Disconf-tool
-====
-
-Disconf-tool是disconf的辅助工具类,主要的功能包括:
-
-1. Disconf-ContextMgr: 一个基于Redis的Context持久化辅助类,方便的将一些频繁更新读取的数据保存起来;**注意,ContextMgr并没有进行行多个分布应用之间读写控制,现阶段该工作应由使用方来完成。**
-2. [TODO]Disconf-Mointor:配置监控类,用于及时发现应用与服务间配置的不一致并报警;

+ 0 - 71
disconf-tool/pom.xml

@@ -1,71 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>com.baidu.disconf</groupId>
-        <artifactId>disconf-base</artifactId>
-        <version>2.6.28</version>
-    </parent>
-
-    <artifactId>disconf-tool</artifactId>
-    <version>${disconf-tool.version}</version>
-    <name>disconf-tools</name>
-    <description>tools for disconf extension</description>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>com.baidu.disconf</groupId>
-            <artifactId>disconf-core</artifactId>
-            <version>${disconf-core.version}</version>
-        </dependency>
-
-        <!-- common -->
-
-        <dependency>
-            <groupId>redis.clients</groupId>
-            <artifactId>jedis</artifactId>
-        </dependency>
-
-        <!-- spring -->
-
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-beans</artifactId>
-        </dependency>
-
-        <!-- log -->
-
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
-
-        <!-- test -->
-
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>com.googlecode.jmockit</groupId>
-            <artifactId>jmockit</artifactId>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-
-</project>

+ 0 - 85
disconf-tool/src/main/java/com/baidu/disconf/tool/context/ContextMgr.java

@@ -1,85 +0,0 @@
-package com.baidu.disconf.tool.context;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.github.knightliao.apollo.redis.RedisClient;
-import com.github.knightliao.apollo.redis.config.RedisHAClientConfig;
-import com.github.knightliao.apollo.utils.data.JsonUtils;
-
-/**
- * @author : WuNing
- * @description : ContextMgr 通过一个Redis服务器保存主机的Context信息
- * @date : 2014年7月29日 下午3:56:11
- */
-
-public class ContextMgr {
-
-    Logger logger = LoggerFactory.getLogger(ContextMgr.class);
-
-    RedisClient client = null;
-
-    /**
-     * @param redisServer
-     * @param port
-     * @param authKey
-     * @param timeOut
-     *
-     * @description: 通过一个Redis服务,初始化ContextMgr
-     */
-    public ContextMgr(String redisServer, int port, String authKey, int timeOut) {
-
-        RedisHAClientConfig clientConfig = new RedisHAClientConfig();
-        clientConfig.setRedisAuthKey(authKey);
-        clientConfig.setRedisServerHost(redisServer);
-        clientConfig.setRedisServerPort(port);
-        clientConfig.setTimeout(timeOut);
-
-        client = new RedisClient(clientConfig);
-
-        client.flushall();
-    }
-
-    /**
-     * 远程保存一个环境变量的值
-     *
-     * @param key
-     * @param obj
-     */
-    public void save(String key, String field, Object obj) {
-        String str = JsonUtils.toJson(obj);
-        try {
-            client.hput(key, field, str);
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-        }
-        logger.info("[Disconf Context Save]" + key + ":" + field + " : " + str);
-    }
-
-    /**
-     * 加载一个环境变量的值 当值加载失败后,返回默认值
-     *
-     * @param key
-     * @param clz
-     * @param defaultVal 默认值,可以为空,要求类型就是clz,
-     *
-     * @return
-     */
-    @SuppressWarnings("unchecked")
-    public Object load(String key, String field, Class clz, Object defaultVal) {
-
-        String jsonStr = (String) client.hget(key, field);
-
-        logger.info("[Disconf Context Load]" + key + ":" + field + " : " + jsonStr);
-
-        Object ret = JsonUtils.json2Object(jsonStr, clz);
-
-        // json2Object return "" when error happens
-        if ("".equals(ret)) {
-            ret = defaultVal;
-        }
-
-        return ret;
-    }
-
-}

+ 0 - 165
disconf-tool/src/test/java/com/baidu/disconf/tool/context/test/ContextMgrTestCase.java

@@ -1,165 +0,0 @@
-package com.baidu.disconf.tool.context.test;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.baidu.disconf.tool.context.ContextMgr;
-import com.github.knightliao.apollo.redis.RedisClient;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import mockit.Mock;
-import mockit.MockUp;
-import mockit.integration.junit4.JMockit;
-
-/**
- * @author : WuNing
- * @description : ContextMgrTestCase
- * @date : 2014年8月1日 下午5:30:00
- */
-@RunWith(JMockit.class)
-public class ContextMgrTestCase extends TestCase {
-
-    static final Logger logger = LoggerFactory.getLogger(ContextMgrTestCase.class);
-
-    @Before
-    public void setUp() {
-        logger.info("mockup initial begin");
-        new MockUp<RedisClient>() {
-            Map<String, String> redisStorage = new HashMap<String, String>();
-
-            @Mock
-            public boolean flushall() {
-                logger.info("Redis Client Flush");
-                return true;
-            }
-
-            @Mock
-            public void hput(String key, String field, Serializable fieldValue) {
-                redisStorage.put(key + "_" + field, fieldValue.toString());
-            }
-
-            @Mock
-            public Object hget(String key, String field) {
-                return redisStorage.get(key + "_" + field);
-            }
-
-        };
-
-        logger.info("mockup initial done");
-    }
-
-    @Test
-    public void testSaveLoadInt() {
-
-        logger.info("begin to test save and load");
-
-        ContextMgr mgr = new ContextMgr("127.0.0.1", 8000, "authkey", 300);
-
-        // Int
-        mgr.save("KEY", "INT_VAL", 10);
-        int val = (Integer) mgr.load("KEY", "INT_VAL", Integer.class, 0);
-        Assert.assertEquals(val, 10);
-
-    }
-
-    @Test
-    public void testSaveLoadStr() {
-        logger.info("begin to test save and load");
-
-        ContextMgr mgr = new ContextMgr("127.0.0.1", 8000, "authkey", 300);
-
-        // String
-        String str = "IMPORT INFORMATION";
-        mgr.save("KEY", "STR_VAL", str);
-        String str2 = (String) mgr.load("KEY", "STR_VAL", String.class, "");
-        Assert.assertEquals(str, str2);
-    }
-
-    @Test
-    public void testSaveLoadComplexClass() {
-        logger.info("begin to test save and load");
-
-        ContextMgr mgr = new ContextMgr("127.0.0.1", 8000, "authkey", 300);
-
-        ComplexClass complex = new ComplexClass();
-        complex.intVal = 42;
-        complex.doubleVal = Math.PI;
-        complex.strList.add("Hello,world");
-        complex.strList.add("Disconf rocks!");
-
-        mgr.save("KEY", "COMPLEX_VAL", complex);
-        ComplexClass complex2 = (ComplexClass) mgr.load("KEY", "COMPLEX_VAL", ComplexClass.class, null);
-
-        Assert.assertTrue(complex.equals(complex2));
-
-    }
-
-    public static class ComplexClass {
-        int intVal;
-        double doubleVal;
-        List<String> strList = new ArrayList<String>();
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            ComplexClass other = (ComplexClass) obj;
-            if (Double.doubleToLongBits(doubleVal) != Double.doubleToLongBits(other.doubleVal)) {
-                return false;
-            }
-            if (intVal != other.intVal) {
-                return false;
-            }
-            if (strList == null) {
-                if (other.strList != null) {
-                    return false;
-                }
-            } else if (!strList.equals(other.strList)) {
-                return false;
-            }
-            return true;
-        }
-
-        public int getIntVal() {
-            return intVal;
-        }
-
-        public void setIntVal(int intVal) {
-            this.intVal = intVal;
-        }
-
-        public double getDoubleVal() {
-            return doubleVal;
-        }
-
-        public void setDoubleVal(double doubleVal) {
-            this.doubleVal = doubleVal;
-        }
-
-        public List<String> getStrList() {
-            return strList;
-        }
-
-        public void setStrList(List<String> strList) {
-            this.strList = strList;
-        }
-    }
-
-}

+ 0 - 17
disconf-tool/src/test/java/com/baidu/disconf/tool/test/TestSuite.java

@@ -1,17 +0,0 @@
-package com.baidu.disconf.tool.test;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-import com.baidu.disconf.tool.context.test.ContextMgrTestCase;
-
-/**
- * @author liaoqiqi
- * @version 2014-7-30
- */
-@RunWith(Suite.class)
-@SuiteClasses({ContextMgrTestCase.class})
-public class TestSuite {
-
-}

+ 1 - 0
disconf-web/pom.xml

@@ -115,6 +115,7 @@
         <dependency>
             <groupId>com.github.knightliao.apollo</groupId>
             <artifactId>apollo</artifactId>
+            <version>1.0.12</version>
         </dependency>
 
         <!-- common dependencies -->

+ 3 - 13
pom.xml

@@ -5,13 +5,12 @@
 
     <groupId>com.baidu.disconf</groupId>
     <artifactId>disconf-base</artifactId>
-    <version>2.6.28</version>
+    <version>2.6.29-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <modules>
         <module>disconf-client</module>
         <module>disconf-core</module>
-        <module>disconf-tool</module>
     </modules>
 
     <inceptionYear>2015</inceptionYear>
@@ -26,9 +25,8 @@
 
     <properties>
         <!-- 模块版本号 -->
-        <disconf-core.version>2.6.28</disconf-core.version>
-        <disconf-client.version>2.6.28</disconf-client.version>
-        <disconf-tool.version>2.6.28</disconf-tool.version>
+        <disconf-core.version>2.6.29-SNAPSHOT</disconf-core.version>
+        <disconf-client.version>2.6.29-SNAPSHOT</disconf-client.version>
 
         <!-- Spring項目配置 -->
         <encoding>UTF-8</encoding>
@@ -55,14 +53,6 @@
     <dependencyManagement>
         <dependencies>
 
-            <!-- my dependencies -->
-
-            <dependency>
-                <groupId>com.github.knightliao.apollo</groupId>
-                <artifactId>apollo</artifactId>
-                <version>1.0.12</version>
-            </dependency>
-
             <!-- common dependencies -->
 
             <dependency>