Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
f048baff
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f048baff
编写于
4月 25, 2017
作者:
J
Jason Song
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use guice as apollo-client ioc mechanism
上级
c219ee89
变更
74
隐藏空白更改
内联
并排
Showing
74 changed file
with
834 addition
and
985 deletion
+834
-985
apollo-adminservice/pom.xml
apollo-adminservice/pom.xml
+1
-1
apollo-assembly/pom.xml
apollo-assembly/pom.xml
+1
-1
apollo-biz/pom.xml
apollo-biz/pom.xml
+1
-1
apollo-buildtools/pom.xml
apollo-buildtools/pom.xml
+1
-1
apollo-client/README.md
apollo-client/README.md
+1
-1
apollo-client/pom.xml
apollo-client/pom.xml
+5
-19
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
...c/main/java/com/ctrip/framework/apollo/ConfigService.java
+4
-27
apollo-client/src/main/java/com/ctrip/framework/apollo/build/ApolloInjector.java
...java/com/ctrip/framework/apollo/build/ApolloInjector.java
+51
-0
apollo-client/src/main/java/com/ctrip/framework/apollo/build/ComponentConfigurator.java
...m/ctrip/framework/apollo/build/ComponentConfigurator.java
+0
-41
apollo-client/src/main/java/com/ctrip/framework/apollo/ds/ApolloDataSourceProvider.java
...m/ctrip/framework/apollo/ds/ApolloDataSourceProvider.java
+0
-72
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java
.../com/ctrip/framework/apollo/internals/AbstractConfig.java
+21
-28
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java
.../ctrip/framework/apollo/internals/AbstractConfigFile.java
+5
-5
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java
.../framework/apollo/internals/AbstractConfigRepository.java
+5
-6
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java
...trip/framework/apollo/internals/ConfigServiceLocator.java
+20
-30
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
...a/com/ctrip/framework/apollo/internals/DefaultConfig.java
+11
-12
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java
...trip/framework/apollo/internals/DefaultConfigManager.java
+7
-8
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultInjector.java
...com/ctrip/framework/apollo/internals/DefaultInjector.java
+65
-0
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/Injector.java
...n/java/com/ctrip/framework/apollo/internals/Injector.java
+17
-0
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
...framework/apollo/internals/LocalFileConfigRepository.java
+15
-25
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java
...trip/framework/apollo/internals/PropertiesConfigFile.java
+6
-6
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
...amework/apollo/internals/RemoteConfigLongPollService.java
+29
-38
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java
...ip/framework/apollo/internals/RemoteConfigRepository.java
+27
-37
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
...va/com/ctrip/framework/apollo/internals/SimpleConfig.java
+10
-11
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
.../com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
+8
-7
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java
...rip/framework/apollo/spi/DefaultConfigFactoryManager.java
+13
-17
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java
...com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java
+7
-16
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java
...k/apollo/spring/annotation/ApolloAnnotationProcessor.java
+7
-8
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java
...trip/framework/apollo/spring/annotation/ApolloConfig.java
+2
-2
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfigChangeListener.java
.../apollo/spring/annotation/ApolloConfigChangeListener.java
+2
-2
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfigRegistrar.java
...ework/apollo/spring/annotation/ApolloConfigRegistrar.java
+4
-5
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java
...ramework/apollo/spring/annotation/EnableApolloConfig.java
+5
-5
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/ConfigPropertySource.java
.../framework/apollo/spring/config/ConfigPropertySource.java
+1
-0
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/ConfigPropertySourcesProcessor.java
.../apollo/spring/config/ConfigPropertySourcesProcessor.java
+3
-3
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/NamespaceHandler.java
...trip/framework/apollo/spring/config/NamespaceHandler.java
+4
-5
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
...mework/apollo/spring/config/PropertySourcesProcessor.java
+7
-9
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/util/BeanRegistrationUtil.java
...ip/framework/apollo/spring/util/BeanRegistrationUtil.java
+2
-2
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
...main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
+5
-8
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ExceptionUtil.java
...n/java/com/ctrip/framework/apollo/util/ExceptionUtil.java
+2
-2
apollo-client/src/main/java/com/ctrip/framework/apollo/util/function/Functions.java
...a/com/ctrip/framework/apollo/util/function/Functions.java
+2
-3
apollo-client/src/main/java/com/ctrip/framework/apollo/util/http/HttpUtil.java
...n/java/com/ctrip/framework/apollo/util/http/HttpUtil.java
+17
-21
apollo-client/src/main/resources/META-INF/plexus/components.xml
...-client/src/main/resources/META-INF/plexus/components.xml
+0
-75
apollo-client/src/main/resources/META-INF/services/com.ctrip.framework.apollo.internals.Injector
...NF/services/com.ctrip.framework.apollo.internals.Injector
+1
-0
apollo-client/src/test/java/com/ctrip/framework/apollo/AllTests.java
...nt/src/test/java/com/ctrip/framework/apollo/AllTests.java
+4
-4
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
.../java/com/ctrip/framework/apollo/BaseIntegrationTest.java
+23
-24
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java
...st/java/com/ctrip/framework/apollo/ConfigServiceTest.java
+17
-16
apollo-client/src/test/java/com/ctrip/framework/apollo/build/MockInjector.java
...t/java/com/ctrip/framework/apollo/build/MockInjector.java
+64
-0
apollo-client/src/test/java/com/ctrip/framework/apollo/integration/ConfigIntegrationTest.java
...p/framework/apollo/integration/ConfigIntegrationTest.java
+29
-29
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java
.../framework/apollo/internals/DefaultConfigManagerTest.java
+17
-16
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java
...m/ctrip/framework/apollo/internals/DefaultConfigTest.java
+27
-30
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java
.../ctrip/framework/apollo/internals/JsonConfigFileTest.java
+9
-9
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java
...ework/apollo/internals/LocalFileConfigRepositoryTest.java
+20
-23
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java
.../framework/apollo/internals/PropertiesConfigFileTest.java
+8
-8
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
...ork/apollo/internals/RemoteConfigLongPollServiceTest.java
+39
-49
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
...ramework/apollo/internals/RemoteConfigRepositoryTest.java
+45
-55
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java
...om/ctrip/framework/apollo/internals/SimpleConfigTest.java
+11
-12
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java
...m/ctrip/framework/apollo/internals/XmlConfigFileTest.java
+9
-9
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java
...framework/apollo/spi/DefaultConfigFactoryManagerTest.java
+15
-17
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java
.../ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java
+21
-22
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java
...ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java
+10
-11
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
...ramework/apollo/spring/AbstractSpringIntegrationTest.java
+15
-22
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java
...rip/framework/apollo/spring/JavaConfigAnnotationTest.java
+13
-14
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java
...ip/framework/apollo/spring/JavaConfigPlaceholderTest.java
+8
-8
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XMLConfigAnnotationTest.java
...trip/framework/apollo/spring/XMLConfigAnnotationTest.java
+12
-13
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderTest.java
...rip/framework/apollo/spring/XmlConfigPlaceholderTest.java
+7
-7
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ExceptionUtilTest.java
...va/com/ctrip/framework/apollo/util/ExceptionUtilTest.java
+2
-2
apollo-client/src/test/java/com/ctrip/framework/apollo/util/parser/DateParserTest.java
...om/ctrip/framework/apollo/util/parser/DateParserTest.java
+2
-2
apollo-client/src/test/java/com/ctrip/framework/apollo/util/parser/DurationParserTest.java
...trip/framework/apollo/util/parser/DurationParserTest.java
+2
-2
apollo-client/src/test/resources/META-INF/services/com.ctrip.framework.apollo.internals.Injector
...NF/services/com.ctrip.framework.apollo.internals.Injector
+1
-0
apollo-common/pom.xml
apollo-common/pom.xml
+1
-1
apollo-configservice/pom.xml
apollo-configservice/pom.xml
+1
-1
apollo-core/pom.xml
apollo-core/pom.xml
+1
-1
apollo-demo/pom.xml
apollo-demo/pom.xml
+1
-1
apollo-portal/pom.xml
apollo-portal/pom.xml
+1
-1
pom.xml
pom.xml
+4
-16
未找到文件。
apollo-adminservice/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
apollo-assembly/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
apollo-biz/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apollo-biz
</artifactId>
...
...
apollo-buildtools/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
apollo-client/README.md
浏览文件 @
f048baff
...
...
@@ -88,7 +88,7 @@ If you need this functionality, you could specify the cluster as follows:
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-client
</artifactId>
<version>
0.
6.4
</version>
<version>
0.
7.0
</version>
</dependency>
## III. Client Usage
...
...
apollo-client/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
@@ -21,12 +21,12 @@
<artifactId>
apollo-core
</artifactId>
</dependency>
<!-- end of apollo -->
<!--
foundation serv
ice -->
<!--
gu
ice -->
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
foundation-serv
ice
</artifactId>
<groupId>
com.google.inject
</groupId>
<artifactId>
gu
ice
</artifactId>
</dependency>
<!-- end of
foundation serv
ice -->
<!-- end of
gu
ice -->
<!-- log -->
<dependency>
<groupId>
org.slf4j
</groupId>
...
...
@@ -61,19 +61,5 @@
<scope>
test
</scope>
</dependency>
<!-- end of test -->
<!-- dal-jdbc -->
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
dal-jdbc
</artifactId>
<version>
2.4.0
</version>
<optional>
true
</optional>
<exclusions>
<exclusion>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-client
</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- end of dal-jdbc -->
</dependencies>
</project>
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.internals.ConfigManager
;
import
com.ctrip.framework.apollo.spi.ConfigFactory
;
import
com.ctrip.framework.apollo.spi.ConfigRegistry
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.codehaus.plexus.PlexusContainer
;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException
;
import
org.unidal.lookup.ContainerLoader
;
/**
* Entry point for client config use
...
...
@@ -20,25 +15,14 @@ import org.unidal.lookup.ContainerLoader;
public
class
ConfigService
{
private
static
final
ConfigService
s_instance
=
new
ConfigService
();
private
PlexusContainer
m_container
;
private
volatile
ConfigManager
m_configManager
;
private
volatile
ConfigRegistry
m_configRegistry
;
private
ConfigService
()
{
m_container
=
ContainerLoader
.
getDefaultContainer
();
}
private
ConfigManager
getManager
()
{
if
(
m_configManager
==
null
)
{
synchronized
(
this
)
{
if
(
m_configManager
==
null
)
{
try
{
m_configManager
=
m_container
.
lookup
(
ConfigManager
.
class
);
}
catch
(
ComponentLookupException
ex
)
{
ApolloConfigException
exception
=
new
ApolloConfigException
(
"Unable to load ConfigManager!"
,
ex
);
Tracer
.
logError
(
exception
);
throw
exception
;
}
m_configManager
=
ApolloInjector
.
getInstance
(
ConfigManager
.
class
);
}
}
}
...
...
@@ -50,13 +34,7 @@ public class ConfigService {
if
(
m_configRegistry
==
null
)
{
synchronized
(
this
)
{
if
(
m_configRegistry
==
null
)
{
try
{
m_configRegistry
=
m_container
.
lookup
(
ConfigRegistry
.
class
);
}
catch
(
ComponentLookupException
ex
)
{
ApolloConfigException
exception
=
new
ApolloConfigException
(
"Unable to load ConfigRegistry!"
,
ex
);
Tracer
.
logError
(
exception
);
throw
exception
;
}
m_configRegistry
=
ApolloInjector
.
getInstance
(
ConfigRegistry
.
class
);
}
}
}
...
...
@@ -127,9 +105,8 @@ public class ConfigService {
}
// for test only
static
void
setContainer
(
PlexusContainer
m_container
)
{
static
void
reset
(
)
{
synchronized
(
s_instance
)
{
s_instance
.
m_container
=
m_container
;
s_instance
.
m_configManager
=
null
;
s_instance
.
m_configRegistry
=
null
;
}
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/build/ApolloInjector.java
0 → 100644
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.build
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.internals.Injector
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.foundation.internals.ServiceBootstrap
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
ApolloInjector
{
private
static
Injector
s_injector
;
private
static
Object
lock
=
new
Object
();
private
static
Injector
getInjector
()
{
if
(
s_injector
==
null
)
{
synchronized
(
lock
)
{
if
(
s_injector
==
null
)
{
try
{
s_injector
=
ServiceBootstrap
.
loadFirst
(
Injector
.
class
);
}
catch
(
Throwable
ex
)
{
ApolloConfigException
exception
=
new
ApolloConfigException
(
"Unable to initialize Apollo Injector!"
,
ex
);
Tracer
.
logError
(
exception
);
throw
exception
;
}
}
}
}
return
s_injector
;
}
public
static
<
T
>
T
getInstance
(
Class
<
T
>
clazz
)
{
try
{
return
getInjector
().
getInstance
(
clazz
);
}
catch
(
Throwable
ex
)
{
Tracer
.
logError
(
ex
);
throw
new
ApolloConfigException
(
String
.
format
(
"Unable to load instance for type %s!"
,
clazz
.
getName
()),
ex
);
}
}
public
static
<
T
>
T
getInstance
(
Class
<
T
>
clazz
,
String
name
)
{
try
{
return
getInjector
().
getInstance
(
clazz
,
name
);
}
catch
(
Throwable
ex
)
{
Tracer
.
logError
(
ex
);
throw
new
ApolloConfigException
(
String
.
format
(
"Unable to load instance for type %s and name %s !"
,
clazz
.
getName
(),
name
),
ex
);
}
}
}
apollo-client/src/main/java/com/ctrip/framework/apollo/build/ComponentConfigurator.java
已删除
100644 → 0
浏览文件 @
c219ee89
package
com.ctrip.framework.apollo.build
;
import
com.ctrip.framework.apollo.internals.ConfigServiceLocator
;
import
com.ctrip.framework.apollo.internals.DefaultConfigManager
;
import
com.ctrip.framework.apollo.internals.RemoteConfigLongPollService
;
import
com.ctrip.framework.apollo.spi.DefaultConfigFactory
;
import
com.ctrip.framework.apollo.spi.DefaultConfigFactoryManager
;
import
com.ctrip.framework.apollo.spi.DefaultConfigRegistry
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
org.unidal.lookup.configuration.AbstractResourceConfigurator
;
import
org.unidal.lookup.configuration.Component
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
ComponentConfigurator
extends
AbstractResourceConfigurator
{
public
static
void
main
(
String
[]
args
)
{
generatePlexusComponentsXmlFile
(
new
ComponentConfigurator
());
}
@Override
public
List
<
Component
>
defineComponents
()
{
List
<
Component
>
all
=
new
ArrayList
<>();
all
.
add
(
A
(
DefaultConfigManager
.
class
));
all
.
add
(
A
(
DefaultConfigFactory
.
class
));
all
.
add
(
A
(
DefaultConfigRegistry
.
class
));
all
.
add
(
A
(
DefaultConfigFactoryManager
.
class
));
all
.
add
(
A
(
ConfigUtil
.
class
));
all
.
add
(
A
(
HttpUtil
.
class
));
all
.
add
(
A
(
ConfigServiceLocator
.
class
));
all
.
add
(
A
(
RemoteConfigLongPollService
.
class
));
return
all
;
}
}
apollo-client/src/main/java/com/ctrip/framework/apollo/ds/ApolloDataSourceProvider.java
已删除
100644 → 0
浏览文件 @
c219ee89
package
com.ctrip.framework.apollo.ds
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.foundation.Foundation
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.unidal.dal.jdbc.datasource.DataSourceProvider
;
import
org.unidal.dal.jdbc.datasource.model.entity.DataSourcesDef
;
import
org.unidal.dal.jdbc.datasource.model.transform.DefaultSaxParser
;
import
org.unidal.lookup.annotation.Named
;
/**
* Data source provider based on Apollo configuration service.
* <p>
*
* Use following component definition to replace default
* <code>DataSourceProvider</code>:
* <p>
* <code><pre>
* public List<Component> defineComponents() {
* List<Component> all = new ArrayList<>();
*
* all.add(A(ApolloDataSourceProvider.class));
*
* return all;
* }
* </pre></code>
*
* <b>WARNING:</b> all defined <code>DataSourceProvider</code> components will
* be taken affect. DO NOT define unused <code>DataSourceProvider</code>
* component.
*/
@Named
(
type
=
DataSourceProvider
.
class
,
value
=
"apollo"
)
public
class
ApolloDataSourceProvider
implements
DataSourceProvider
,
LogEnabled
{
private
Logger
m_logger
;
private
DataSourcesDef
m_def
;
@Override
public
DataSourcesDef
defineDatasources
()
{
if
(
m_def
==
null
)
{
ConfigFile
file
=
ConfigService
.
getConfigFile
(
"datasources"
,
ConfigFileFormat
.
XML
);
String
appId
=
Foundation
.
app
().
getAppId
();
String
envType
=
Foundation
.
server
().
getEnvType
();
if
(
file
!=
null
&&
file
.
hasContent
())
{
String
content
=
file
.
getContent
();
m_logger
.
info
(
String
.
format
(
"Found datasources.xml from Apollo(env=%s, app.id=%s)!"
,
envType
,
appId
));
try
{
m_def
=
DefaultSaxParser
.
parse
(
content
);
}
catch
(
Exception
e
)
{
throw
new
IllegalStateException
(
String
.
format
(
"Error when parsing datasources.xml from Apollo(env=%s, app.id=%s)!"
,
envType
,
appId
),
e
);
}
}
else
{
m_logger
.
warn
(
String
.
format
(
"Can't get datasources.xml from Apollo(env=%s, app.id=%s)!"
,
envType
,
appId
));
m_def
=
new
DataSourcesDef
();
}
}
return
m_def
;
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
}
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.base.Function
;
import
com.google.common.base.Objects
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.atomic.AtomicLong
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.enums.PropertyChangeType
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
...
...
@@ -20,21 +26,13 @@ import com.ctrip.framework.apollo.tracer.spi.Transaction;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.function.Functions
;
import
com.ctrip.framework.apollo.util.parser.Parsers
;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.unidal.lookup.ContainerLoader
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.atomic.AtomicLong
;
import
com.google.common.base.Function
;
import
com.google.common.base.Objects
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
@@ -65,15 +63,10 @@ public abstract class AbstractConfig implements Config {
}
public
AbstractConfig
()
{
try
{
m_configUtil
=
ContainerLoader
.
getDefaultContainer
().
lookup
(
ConfigUtil
.
class
);
m_configUtil
=
ApolloInjector
.
getInstance
(
ConfigUtil
.
class
);
m_configVersion
=
new
AtomicLong
();
m_arrayCache
=
Maps
.
newConcurrentMap
();
allCaches
=
Lists
.
newArrayList
();
}
catch
(
ComponentLookupException
ex
)
{
Tracer
.
logError
(
ex
);
throw
new
ApolloConfigException
(
"Unable to load component!"
,
ex
);
}
}
@Override
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
java.util.Properties
;
import
java.util.concurrent.atomic.AtomicReference
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Properties
;
import
java.util.concurrent.atomic.AtomicReference
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.collect.Lists
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
java.util.List
;
import
java.util.Properties
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.List
;
import
java.util.Properties
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.google.common.collect.Lists
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.escape.Escaper
;
import
com.google.common.net.UrlEscapers
;
import
com.google.gson.reflect.TypeToken
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.atomic.AtomicReference
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
...
...
@@ -18,28 +21,17 @@ import com.ctrip.framework.apollo.util.ExceptionUtil;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.escape.Escaper
;
import
com.google.common.net.UrlEscapers
;
import
com.google.gson.reflect.TypeToken
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Named
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicReference
;
@Named
(
type
=
ConfigServiceLocator
.
class
)
public
class
ConfigServiceLocator
implements
Initializable
{
public
class
ConfigServiceLocator
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ConfigServiceLocator
.
class
);
@Inject
private
HttpUtil
m_httpUtil
;
@Inject
private
ConfigUtil
m_configUtil
;
private
AtomicReference
<
List
<
ServiceDTO
>>
m_configServices
;
private
Type
m_responseType
;
...
...
@@ -55,12 +47,10 @@ public class ConfigServiceLocator implements Initializable {
m_configServices
=
new
AtomicReference
<>(
initial
);
m_responseType
=
new
TypeToken
<
List
<
ServiceDTO
>>()
{
}.
getType
();
m_httpUtil
=
ApolloInjector
.
getInstance
(
HttpUtil
.
class
);
m_configUtil
=
ApolloInjector
.
getInstance
(
ConfigUtil
.
class
);
this
.
m_executorService
=
Executors
.
newScheduledThreadPool
(
1
,
ApolloThreadFactory
.
create
(
"ConfigServiceLocator"
,
true
));
}
@Override
public
void
initialize
()
throws
InitializationException
{
this
.
tryUpdateConfigServices
();
this
.
schedulePeriodicRefresh
();
}
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.collect.ImmutableMap
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.enums.PropertyChangeType
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Collections
;
...
...
@@ -22,6 +10,17 @@ import java.util.Properties;
import
java.util.Set
;
import
java.util.concurrent.atomic.AtomicReference
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.enums.PropertyChangeType
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.google.common.collect.ImmutableMap
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.collect.Maps
;
import
java.util.Map
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.spi.ConfigFactory
;
import
com.ctrip.framework.apollo.spi.ConfigFactoryManager
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Named
;
import
java.util.Map
;
import
com.google.common.collect.Maps
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Named
(
type
=
ConfigManager
.
class
)
public
class
DefaultConfigManager
implements
ConfigManager
{
@Inject
private
ConfigFactoryManager
m_factoryManager
;
private
Map
<
String
,
Config
>
m_configs
=
Maps
.
newConcurrentMap
();
private
Map
<
String
,
ConfigFile
>
m_configFiles
=
Maps
.
newConcurrentMap
();
public
DefaultConfigManager
()
{
m_factoryManager
=
ApolloInjector
.
getInstance
(
ConfigFactoryManager
.
class
);
}
@Override
public
Config
getConfig
(
String
namespace
)
{
Config
config
=
m_configs
.
get
(
namespace
);
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultInjector.java
0 → 100644
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.spi.ConfigFactory
;
import
com.ctrip.framework.apollo.spi.ConfigFactoryManager
;
import
com.ctrip.framework.apollo.spi.ConfigRegistry
;
import
com.ctrip.framework.apollo.spi.DefaultConfigFactory
;
import
com.ctrip.framework.apollo.spi.DefaultConfigFactoryManager
;
import
com.ctrip.framework.apollo.spi.DefaultConfigRegistry
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
com.google.inject.AbstractModule
;
import
com.google.inject.Guice
;
import
com.google.inject.Singleton
;
/**
* Guice injector
* @author Jason Song(song_s@ctrip.com)
*/
public
class
DefaultInjector
implements
Injector
{
private
com
.
google
.
inject
.
Injector
m_injector
;
public
DefaultInjector
()
{
try
{
m_injector
=
Guice
.
createInjector
(
new
ApolloModule
());
}
catch
(
Throwable
ex
)
{
ApolloConfigException
exception
=
new
ApolloConfigException
(
"Unable to initialize Guice Injector!"
,
ex
);
Tracer
.
logError
(
exception
);
throw
exception
;
}
}
@Override
public
<
T
>
T
getInstance
(
Class
<
T
>
clazz
)
{
try
{
return
m_injector
.
getInstance
(
clazz
);
}
catch
(
Throwable
ex
)
{
Tracer
.
logError
(
ex
);
throw
new
ApolloConfigException
(
String
.
format
(
"Unable to load instance for %s!"
,
clazz
.
getName
()),
ex
);
}
}
@Override
public
<
T
>
T
getInstance
(
Class
<
T
>
clazz
,
String
name
)
{
//Guice does not support get instance by type and name
return
null
;
}
private
static
class
ApolloModule
extends
AbstractModule
{
@Override
protected
void
configure
()
{
bind
(
ConfigManager
.
class
).
to
(
DefaultConfigManager
.
class
).
in
(
Singleton
.
class
);
bind
(
ConfigFactoryManager
.
class
).
to
(
DefaultConfigFactoryManager
.
class
).
in
(
Singleton
.
class
);
bind
(
ConfigRegistry
.
class
).
to
(
DefaultConfigRegistry
.
class
).
in
(
Singleton
.
class
);
bind
(
ConfigFactory
.
class
).
to
(
DefaultConfigFactory
.
class
).
in
(
Singleton
.
class
);
bind
(
ConfigUtil
.
class
).
in
(
Singleton
.
class
);
bind
(
HttpUtil
.
class
).
in
(
Singleton
.
class
);
bind
(
ConfigServiceLocator
.
class
).
in
(
Singleton
.
class
);
bind
(
RemoteConfigLongPollService
.
class
).
in
(
Singleton
.
class
);
}
}
}
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/Injector.java
0 → 100644
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
interface
Injector
{
/**
* Returns the appropriate instance for the given injection type
*/
<
T
>
T
getInstance
(
Class
<
T
>
clazz
);
/**
* Returns the appropriate instance for the given injection type and name
*/
<
T
>
T
getInstance
(
Class
<
T
>
clazz
,
String
name
);
}
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Preconditions
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
org.codehaus.plexus.PlexusContainer
;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.unidal.lookup.ContainerLoader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
...
...
@@ -28,6 +11,20 @@ import java.nio.file.Path;
import
java.nio.file.Paths
;
import
java.util.Properties
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.spi.Transaction
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Preconditions
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
@@ -35,7 +32,6 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
implements
RepositoryChangeListener
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LocalFileConfigRepository
.
class
);
private
static
final
String
CONFIG_DIR
=
"/config-cache"
;
private
final
PlexusContainer
m_container
;
private
final
String
m_namespace
;
private
File
m_baseDir
;
private
final
ConfigUtil
m_configUtil
;
...
...
@@ -53,13 +49,7 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
public
LocalFileConfigRepository
(
String
namespace
,
ConfigRepository
upstream
)
{
m_namespace
=
namespace
;
m_container
=
ContainerLoader
.
getDefaultContainer
();
try
{
m_configUtil
=
m_container
.
lookup
(
ConfigUtil
.
class
);
}
catch
(
ComponentLookupException
ex
)
{
Tracer
.
logError
(
ex
);
throw
new
ApolloConfigException
(
"Unable to load component!"
,
ex
);
}
m_configUtil
=
ApolloInjector
.
getInstance
(
ConfigUtil
.
class
);
this
.
setLocalCacheDir
(
findLocalCacheDir
(),
false
);
this
.
setUpstreamRepository
(
upstream
);
this
.
trySync
();
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
java.util.Properties
;
import
java.util.concurrent.atomic.AtomicReference
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.utils.PropertiesUtil
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Properties
;
import
java.util.concurrent.atomic.AtomicReference
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.HashMultim
ap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimap
s
;
import
com.google.common.escape.Escaper
;
import
com.google.common.net.UrlEscapers
;
import
com.google.common.reflect.TypeToken
;
import
com.google.common.util.concurrent.RateLimit
er
;
import
com.google.gson.Gson
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.M
ap
;
import
java.util.Random
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executor
s
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
org.slf4j.Logg
er
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
...
...
@@ -28,29 +29,23 @@ import com.ctrip.framework.apollo.util.ExceptionUtil;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Named
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimaps
;
import
com.google.common.escape.Escaper
;
import
com.google.common.net.UrlEscapers
;
import
com.google.common.reflect.TypeToken
;
import
com.google.common.util.concurrent.RateLimiter
;
import
com.google.gson.Gson
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Named
(
type
=
RemoteConfigLongPollService
.
class
)
public
class
RemoteConfigLongPollService
implements
Initializable
{
public
class
RemoteConfigLongPollService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RemoteConfigLongPollService
.
class
);
private
static
final
Joiner
STRING_JOINER
=
Joiner
.
on
(
ConfigConsts
.
CLUSTER_NAMESPACE_SEPARATOR
);
private
static
final
Joiner
.
MapJoiner
MAP_JOINER
=
Joiner
.
on
(
"&"
).
withKeyValueSeparator
(
"="
);
...
...
@@ -65,11 +60,8 @@ public class RemoteConfigLongPollService implements Initializable {
private
final
ConcurrentMap
<
String
,
Long
>
m_notifications
;
private
Type
m_responseType
;
private
Gson
gson
;
@Inject
private
ConfigUtil
m_configUtil
;
@Inject
private
HttpUtil
m_httpUtil
;
@Inject
private
ConfigServiceLocator
m_serviceLocator
;
/**
...
...
@@ -87,10 +79,9 @@ public class RemoteConfigLongPollService implements Initializable {
m_responseType
=
new
TypeToken
<
List
<
ApolloConfigNotification
>>()
{
}.
getType
();
gson
=
new
Gson
();
}
@Override
public
void
initialize
()
throws
InitializationException
{
m_configUtil
=
ApolloInjector
.
getInstance
(
ConfigUtil
.
class
);
m_httpUtil
=
ApolloInjector
.
getInstance
(
HttpUtil
.
class
);
m_serviceLocator
=
ApolloInjector
.
getInstance
(
ConfigServiceLocator
.
class
);
m_longPollRateLimiter
=
RateLimiter
.
create
(
m_configUtil
.
getLongPollQPS
());
}
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.escape.Escaper
;
import
com.google.common.net.UrlEscapers
;
import
com.google.common.util.concurrent.RateLimiter
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicReference
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.Apollo
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfig
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
...
...
@@ -22,21 +27,13 @@ import com.ctrip.framework.apollo.util.ExceptionUtil;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
org.codehaus.plexus.PlexusContainer
;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.unidal.lookup.ContainerLoader
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicReference
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.escape.Escaper
;
import
com.google.common.net.UrlEscapers
;
import
com.google.common.util.concurrent.RateLimiter
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
@@ -45,11 +42,10 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RemoteConfigRepository
.
class
);
private
static
final
Joiner
STRING_JOINER
=
Joiner
.
on
(
ConfigConsts
.
CLUSTER_NAMESPACE_SEPARATOR
);
private
static
final
Joiner
.
MapJoiner
MAP_JOINER
=
Joiner
.
on
(
"&"
).
withKeyValueSeparator
(
"="
);
private
PlexusContainer
m_container
;
private
final
ConfigServiceLocator
m_serviceLocator
;
private
final
HttpUtil
m_httpUtil
;
private
final
ConfigUtil
m_configUtil
;
private
final
RemoteConfigLongPollService
remoteConfigLongPollService
;
private
ConfigServiceLocator
m_serviceLocator
;
private
HttpUtil
m_httpUtil
;
private
ConfigUtil
m_configUtil
;
private
RemoteConfigLongPollService
remoteConfigLongPollService
;
private
volatile
AtomicReference
<
ApolloConfig
>
m_configCache
;
private
final
String
m_namespace
;
private
final
static
ScheduledExecutorService
m_executorService
;
...
...
@@ -71,16 +67,10 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
public
RemoteConfigRepository
(
String
namespace
)
{
m_namespace
=
namespace
;
m_configCache
=
new
AtomicReference
<>();
m_container
=
ContainerLoader
.
getDefaultContainer
();
try
{
m_configUtil
=
m_container
.
lookup
(
ConfigUtil
.
class
);
m_httpUtil
=
m_container
.
lookup
(
HttpUtil
.
class
);
m_serviceLocator
=
m_container
.
lookup
(
ConfigServiceLocator
.
class
);
remoteConfigLongPollService
=
m_container
.
lookup
(
RemoteConfigLongPollService
.
class
);
}
catch
(
ComponentLookupException
ex
)
{
Tracer
.
logError
(
ex
);
throw
new
ApolloConfigException
(
"Unable to load component!"
,
ex
);
}
m_configUtil
=
ApolloInjector
.
getInstance
(
ConfigUtil
.
class
);
m_httpUtil
=
ApolloInjector
.
getInstance
(
HttpUtil
.
class
);
m_serviceLocator
=
ApolloInjector
.
getInstance
(
ConfigServiceLocator
.
class
);
remoteConfigLongPollService
=
ApolloInjector
.
getInstance
(
RemoteConfigLongPollService
.
class
);
m_longPollServiceDto
=
new
AtomicReference
<>();
m_loadConfigRateLimiter
=
RateLimiter
.
create
(
m_configUtil
.
getLoadConfigQPS
());
this
.
trySync
();
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.base.Function
;
import
com.google.common.collect.Maps
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Set
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.google.common.base.Function
;
import
com.google.common.collect.Maps
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spi
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.internals.ConfigRepository
;
import
com.ctrip.framework.apollo.internals.DefaultConfig
;
...
...
@@ -14,20 +18,17 @@ import com.ctrip.framework.apollo.internals.YamlConfigFile;
import
com.ctrip.framework.apollo.internals.YmlConfigFile
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Named
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Named
(
type
=
ConfigFactory
.
class
)
public
class
DefaultConfigFactory
implements
ConfigFactory
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DefaultConfigFactory
.
class
);
@Inject
private
ConfigUtil
m_configUtil
;
public
DefaultConfigFactory
()
{
m_configUtil
=
ApolloInjector
.
getInstance
(
ConfigUtil
.
class
);
}
@Override
public
Config
create
(
String
namespace
)
{
DefaultConfig
defaultConfig
=
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spi
;
import
com.google.common.collect.Maps
;
import
org.unidal.lookup.ContainerHolder
;
import
org.unidal.lookup.LookupException
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Named
;
import
java.util.Map
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.google.common.collect.Maps
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Named
(
type
=
ConfigFactoryManager
.
class
)
public
class
DefaultConfigFactoryManager
extends
ContainerHolder
implements
ConfigFactoryManager
{
@Inject
public
class
DefaultConfigFactoryManager
implements
ConfigFactoryManager
{
private
ConfigRegistry
m_registry
;
private
Map
<
String
,
ConfigFactory
>
m_factories
=
Maps
.
newConcurrentMap
();
public
DefaultConfigFactoryManager
()
{
m_registry
=
ApolloInjector
.
getInstance
(
ConfigRegistry
.
class
);
}
@Override
public
ConfigFactory
getFactory
(
String
namespace
)
{
// step 1: check hacked factory
...
...
@@ -36,16 +34,14 @@ public class DefaultConfigFactoryManager extends ContainerHolder implements Conf
}
// step 3: check declared config factory
try
{
factory
=
lookup
(
ConfigFactory
.
class
,
namespace
);
}
catch
(
LookupException
ex
)
{
// ignore it
factory
=
ApolloInjector
.
getInstance
(
ConfigFactory
.
class
,
namespace
);
if
(
factory
!=
null
)
{
return
factory
;
}
// step 4: check default config factory
if
(
factory
==
null
)
{
factory
=
lookup
(
ConfigFactory
.
class
);
}
factory
=
ApolloInjector
.
getInstance
(
ConfigFactory
.
class
);
m_factories
.
put
(
namespace
,
factory
);
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spi
;
import
com.google.common.collect.Maps
;
import
java.util.Map
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.unidal.lookup.annotation.Named
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Map
;
import
com.google.common.collect.Maps
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Named
(
type
=
ConfigRegistry
.
class
)
public
class
DefaultConfigRegistry
implements
ConfigRegistry
,
LogEnabled
{
public
class
DefaultConfigRegistry
implements
ConfigRegistry
{
private
static
final
Logger
s_logger
=
LoggerFactory
.
getLogger
(
DefaultConfigRegistry
.
class
);
private
Map
<
String
,
ConfigFactory
>
m_instances
=
Maps
.
newConcurrentMap
();
private
Logger
m_logger
;
@Override
public
void
register
(
String
namespace
,
ConfigFactory
factory
)
{
if
(
m_instances
.
containsKey
(
namespace
))
{
m_logger
.
warn
(
String
.
format
(
"ConfigFactory(%s) is overridden by %s!"
,
namespace
,
factory
.
getClass
()));
s_logger
.
warn
(
"ConfigFactory({}) is overridden by {}!"
,
namespace
,
factory
.
getClass
());
}
m_instances
.
put
(
namespace
,
factory
);
...
...
@@ -33,9 +29,4 @@ public class DefaultConfigRegistry implements ConfigRegistry, LogEnabled {
return
config
;
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
}
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.annotation
;
import
com.google.common.base.Preconditions
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
...
...
@@ -14,8 +10,11 @@ import org.springframework.core.PriorityOrdered;
import
org.springframework.core.annotation.AnnotationUtils
;
import
org.springframework.util.ReflectionUtils
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.google.common.base.Preconditions
;
/**
* Apollo Annotation Processor for Spring Application
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.annotation
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
/**
* Use this annotation to inject Apollo Config Instance.
*
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfigChangeListener.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.annotation
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
/**
* Use this annotation to register Apollo ConfigChangeListener.
*
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfigRegistrar.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.annotation
;
import
com.google.common.collect.Lists
;
import
com.ctrip.framework.apollo.spring.config.PropertySourcesProcessor
;
import
com.ctrip.framework.apollo.spring.util.BeanRegistrationUtil
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.context.annotation.ImportBeanDefinitionRegistrar
;
import
org.springframework.context.support.PropertySourcesPlaceholderConfigurer
;
import
org.springframework.core.annotation.AnnotationAttributes
;
import
org.springframework.core.type.AnnotationMetadata
;
import
com.ctrip.framework.apollo.spring.config.PropertySourcesProcessor
;
import
com.ctrip.framework.apollo.spring.util.BeanRegistrationUtil
;
import
com.google.common.collect.Lists
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.annotation
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.core.Ordered
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.core.Ordered
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
/**
* Use this annotation to register Apollo property sources when using Java Config.
*
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/ConfigPropertySource.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.config
;
import
java.util.Set
;
import
org.springframework.core.env.EnumerablePropertySource
;
import
com.ctrip.framework.apollo.Config
;
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/ConfigPropertySourcesProcessor.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.config
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloAnnotationProcessor
;
import
com.ctrip.framework.apollo.spring.util.BeanRegistrationUtil
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
;
import
org.springframework.context.support.PropertySourcesPlaceholderConfigurer
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloAnnotationProcessor
;
import
com.ctrip.framework.apollo.spring.util.BeanRegistrationUtil
;
/**
* Apollo Property Sources processor for Spring XML Based Application
*
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/NamespaceHandler.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.config
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Strings
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
org.springframework.beans.factory.support.BeanDefinitionBuilder
;
import
org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
;
import
org.springframework.beans.factory.xml.NamespaceHandlerSupport
;
import
org.springframework.core.Ordered
;
import
org.w3c.dom.Element
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Strings
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.config
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.ImmutableSortedSet
;
import
com.google.common.collect.Multimap
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.config.BeanFactoryPostProcessor
;
...
...
@@ -17,9 +13,11 @@ import org.springframework.core.env.CompositePropertySource;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.ImmutableSortedSet
;
import
com.google.common.collect.Multimap
;
/**
* Apollo Property Sources processor for Spring Annotation Based Application
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/util/BeanRegistrationUtil.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring.util
;
import
java.util.Objects
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.support.BeanDefinitionBuilder
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
java.util.Objects
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.util
;
import
com.google.common.base.Strings
;
import
java.util.concurrent.TimeUnit
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.MetaDomainConsts
;
...
...
@@ -8,17 +11,11 @@ import com.ctrip.framework.apollo.core.enums.Env;
import
com.ctrip.framework.apollo.core.enums.EnvUtils
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.foundation.Foundation
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.unidal.lookup.annotation.Named
;
import
java.util.concurrent.TimeUnit
;
import
com.google.common.base.Strings
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Named
(
type
=
ConfigUtil
.
class
)
public
class
ConfigUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ConfigUtil
.
class
);
private
static
final
String
TOOLING_CLUSTER
=
"tooling"
;
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ExceptionUtil.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.util
;
import
java.util.List
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Lists
;
import
java.util.List
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/util/function/Functions.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.util.function
;
import
com.google.common.base.Function
;
import
java.util.Date
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.util.parser.ParserException
;
import
com.ctrip.framework.apollo.util.parser.Parsers
;
import
java.util.Date
;
import
com.google.common.base.Function
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/util/http/HttpUtil.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.util.http
;
import
com.google.common.base.Charsets
;
import
com.google.common.base.Function
;
import
com.google.common.io.BaseEncoding
;
import
com.google.gson.Gson
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigStatusCodeException
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
org.unidal.helper.Files
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Named
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.UnsupportedEncodingException
;
import
java.lang.reflect.Type
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigStatusCodeException
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.google.common.base.Function
;
import
com.google.common.io.BaseEncoding
;
import
com.google.common.io.CharStreams
;
import
com.google.gson.Gson
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Named
(
type
=
HttpUtil
.
class
)
public
class
HttpUtil
{
@Inject
private
ConfigUtil
m_configUtil
;
private
Gson
gson
;
private
String
basicAuth
;
...
...
@@ -34,6 +29,7 @@ public class HttpUtil {
* Constructor.
*/
public
HttpUtil
()
{
m_configUtil
=
ApolloInjector
.
getInstance
(
ConfigUtil
.
class
);
gson
=
new
Gson
();
try
{
basicAuth
=
"Basic "
+
BaseEncoding
.
base64
().
encode
(
"user:"
.
getBytes
(
"UTF-8"
));
...
...
@@ -82,7 +78,7 @@ public class HttpUtil {
private
<
T
>
HttpResponse
<
T
>
doGetWithSerializeFunction
(
HttpRequest
httpRequest
,
Function
<
String
,
T
>
serializeFunction
)
{
InputStream
is
=
null
;
InputStream
Reader
isr
=
null
;
int
statusCode
;
try
{
HttpURLConnection
conn
=
(
HttpURLConnection
)
new
URL
(
httpRequest
.
getUrl
()).
openConnection
();
...
...
@@ -108,8 +104,8 @@ public class HttpUtil {
statusCode
=
conn
.
getResponseCode
();
if
(
statusCode
==
200
)
{
is
=
conn
.
getInputStream
(
);
String
content
=
Files
.
IO
.
INSTANCE
.
readFrom
(
is
,
Charsets
.
UTF_8
.
name
()
);
is
r
=
new
InputStreamReader
(
conn
.
getInputStream
()
);
String
content
=
CharStreams
.
toString
(
isr
);
return
new
HttpResponse
<>(
statusCode
,
serializeFunction
.
apply
(
content
));
}
...
...
@@ -120,10 +116,10 @@ public class HttpUtil {
}
catch
(
Throwable
ex
)
{
throw
new
ApolloConfigException
(
"Could not complete get operation"
,
ex
);
}
finally
{
if
(
is
!=
null
)
{
if
(
is
r
!=
null
)
{
try
{
is
.
close
();
}
catch
(
IOException
e
x
)
{
is
r
.
close
();
}
catch
(
IOException
e
)
{
// ignore
}
}
...
...
apollo-client/src/main/resources/META-INF/plexus/components.xml
已删除
100644 → 0
浏览文件 @
c219ee89
<plexus>
<components>
<component>
<role>
com.ctrip.framework.apollo.internals.ConfigManager
</role>
<implementation>
com.ctrip.framework.apollo.internals.DefaultConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.ctrip.framework.apollo.spi.ConfigFactoryManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.ctrip.framework.apollo.spi.ConfigFactory
</role>
<implementation>
com.ctrip.framework.apollo.spi.DefaultConfigFactory
</implementation>
<requirements>
<requirement>
<role>
com.ctrip.framework.apollo.util.ConfigUtil
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.ctrip.framework.apollo.spi.ConfigRegistry
</role>
<implementation>
com.ctrip.framework.apollo.spi.DefaultConfigRegistry
</implementation>
</component>
<component>
<role>
com.ctrip.framework.apollo.spi.ConfigFactoryManager
</role>
<implementation>
com.ctrip.framework.apollo.spi.DefaultConfigFactoryManager
</implementation>
<requirements>
<requirement>
<role>
com.ctrip.framework.apollo.spi.ConfigRegistry
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.ctrip.framework.apollo.util.ConfigUtil
</role>
<implementation>
com.ctrip.framework.apollo.util.ConfigUtil
</implementation>
</component>
<component>
<role>
com.ctrip.framework.apollo.util.http.HttpUtil
</role>
<implementation>
com.ctrip.framework.apollo.util.http.HttpUtil
</implementation>
<requirements>
<requirement>
<role>
com.ctrip.framework.apollo.util.ConfigUtil
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.ctrip.framework.apollo.internals.ConfigServiceLocator
</role>
<implementation>
com.ctrip.framework.apollo.internals.ConfigServiceLocator
</implementation>
<requirements>
<requirement>
<role>
com.ctrip.framework.apollo.util.http.HttpUtil
</role>
</requirement>
<requirement>
<role>
com.ctrip.framework.apollo.util.ConfigUtil
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.ctrip.framework.apollo.internals.RemoteConfigLongPollService
</role>
<implementation>
com.ctrip.framework.apollo.internals.RemoteConfigLongPollService
</implementation>
<requirements>
<requirement>
<role>
com.ctrip.framework.apollo.util.ConfigUtil
</role>
</requirement>
<requirement>
<role>
com.ctrip.framework.apollo.util.http.HttpUtil
</role>
</requirement>
<requirement>
<role>
com.ctrip.framework.apollo.internals.ConfigServiceLocator
</role>
</requirement>
</requirements>
</component>
</components>
</plexus>
apollo-client/src/main/resources/META-INF/services/com.ctrip.framework.apollo.internals.Injector
0 → 100644
浏览文件 @
f048baff
com.ctrip.framework.apollo.internals.DefaultInjector
\ No newline at end of file
apollo-client/src/test/java/com/ctrip/framework/apollo/AllTests.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
import
com.ctrip.framework.apollo.integration.ConfigIntegrationTest
;
import
com.ctrip.framework.apollo.internals.DefaultConfigManagerTest
;
import
com.ctrip.framework.apollo.internals.DefaultConfigTest
;
...
...
@@ -22,10 +26,6 @@ import com.ctrip.framework.apollo.util.ExceptionUtilTest;
import
com.ctrip.framework.apollo.util.parser.DateParserTest
;
import
com.ctrip.framework.apollo.util.parser.DurationParserTest
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
ConfigServiceTest
.
class
,
DefaultConfigRegistryTest
.
class
,
DefaultConfigFactoryManagerTest
.
class
,
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo
;
import
com.google.common.base.Charsets
;
import
com.google.common.collect.Lists
;
import
com.google.common.io.Files
;
import
com.google.gson.Gson
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.ServerSocket
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.eclipse.jetty.server.Request
;
import
org.eclipse.jetty.server.Server
;
...
...
@@ -18,22 +18,22 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.ServerSocket
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.internals.DefaultInjector
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.google.common.base.Charsets
;
import
com.google.common.collect.Lists
;
import
com.google.common.io.Files
;
import
com.google.gson.Gson
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
abstract
class
BaseIntegrationTest
extends
ComponentTestCase
{
public
abstract
class
BaseIntegrationTest
{
private
static
final
int
PORT
=
findFreePort
();
private
static
final
String
metaServiceUrl
=
"http://localhost:"
+
PORT
;
private
static
final
String
someAppName
=
"someAppName"
;
...
...
@@ -56,8 +56,6 @@ public abstract class BaseIntegrationTest extends ComponentTestCase {
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
someAppId
=
"1003171"
;
someClusterName
=
"someClusterName"
;
someDataCenter
=
"someDC"
;
...
...
@@ -65,9 +63,11 @@ public abstract class BaseIntegrationTest extends ComponentTestCase {
refreshTimeUnit
=
TimeUnit
.
MINUTES
;
//as ConfigService is singleton, so we must manually clear its container
ConfigService
.
setContainer
(
getContainer
());
ConfigService
.
reset
();
MockInjector
.
reset
();
MockInjector
.
setDelegate
(
new
DefaultInjector
());
defineComponent
(
ConfigUtil
.
class
,
MockConfigUtil
.
class
);
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
MockConfigUtil
()
);
}
/**
...
...
@@ -93,7 +93,6 @@ public abstract class BaseIntegrationTest extends ComponentTestCase {
if
(
server
!=
null
&&
server
.
isStarted
())
{
server
.
stop
();
}
super
.
tearDown
();
}
protected
ContextHandler
mockMetaServerHandler
()
{
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.util.Set
;
import
org.junit.Before
;
import
org.junit.Test
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.internals.AbstractConfig
;
import
com.ctrip.framework.apollo.internals.DefaultInjector
;
import
com.ctrip.framework.apollo.spi.ConfigFactory
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.util.Set
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
ConfigServiceTest
extends
ComponentTestCase
{
public
class
ConfigServiceTest
{
private
static
String
someAppId
;
@Override
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
someAppId
=
"someAppId"
;
//as ConfigService is singleton, so we must manually clear its container
ConfigService
.
setContainer
(
getContainer
());
defineComponent
(
ConfigUtil
.
class
,
MockConfigUtil
.
class
);
ConfigService
.
reset
();
MockInjector
.
reset
();
MockInjector
.
setDelegate
(
new
DefaultInjector
());
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
MockConfigUtil
());
}
@Test
...
...
@@ -58,7 +59,7 @@ public class ConfigServiceTest extends ComponentTestCase {
public
void
testMockConfigFactory
()
throws
Exception
{
String
someNamespace
=
"mock"
;
String
someKey
=
"someKey"
;
defineComponent
(
ConfigFactory
.
class
,
someNamespace
,
MockConfigFactory
.
class
);
MockInjector
.
setInstance
(
ConfigFactory
.
class
,
someNamespace
,
new
MockConfigFactory
()
);
Config
config
=
ConfigService
.
getConfig
(
someNamespace
);
...
...
@@ -72,7 +73,7 @@ public class ConfigServiceTest extends ComponentTestCase {
ConfigFileFormat
someConfigFileFormat
=
ConfigFileFormat
.
Properties
;
String
someNamespaceFileName
=
String
.
format
(
"%s.%s"
,
someNamespace
,
someConfigFileFormat
.
getValue
());
defineComponent
(
ConfigFactory
.
class
,
someNamespaceFileName
,
MockConfigFactory
.
class
);
MockInjector
.
setInstance
(
ConfigFactory
.
class
,
someNamespaceFileName
,
new
MockConfigFactory
()
);
ConfigFile
configFile
=
ConfigService
.
getConfigFile
(
someNamespace
,
someConfigFileFormat
);
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/build/MockInjector.java
0 → 100644
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.build
;
import
java.util.Map
;
import
com.ctrip.framework.apollo.internals.DefaultInjector
;
import
com.ctrip.framework.apollo.internals.Injector
;
import
com.google.common.collect.HashBasedTable
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Table
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
MockInjector
implements
Injector
{
private
static
Map
<
Class
,
Object
>
classMap
=
Maps
.
newHashMap
();
private
static
Table
<
Class
,
String
,
Object
>
classTable
=
HashBasedTable
.
create
();
private
static
Injector
delegate
=
new
DefaultInjector
();
@Override
public
<
T
>
T
getInstance
(
Class
<
T
>
clazz
)
{
T
o
=
(
T
)
classMap
.
get
(
clazz
);
if
(
o
!=
null
)
{
return
o
;
}
if
(
delegate
!=
null
)
{
return
delegate
.
getInstance
(
clazz
);
}
return
null
;
}
@Override
public
<
T
>
T
getInstance
(
Class
<
T
>
clazz
,
String
name
)
{
T
o
=
(
T
)
classTable
.
get
(
clazz
,
name
);
if
(
o
!=
null
)
{
return
o
;
}
if
(
delegate
!=
null
)
{
return
delegate
.
getInstance
(
clazz
,
name
);
}
return
null
;
}
public
static
void
setInstance
(
Class
clazz
,
Object
o
)
{
classMap
.
put
(
clazz
,
o
);
}
public
static
void
setInstance
(
Class
clazz
,
String
name
,
Object
o
)
{
classTable
.
put
(
clazz
,
name
,
o
);
}
public
static
void
setDelegate
(
Injector
delegateInjector
)
{
delegate
=
delegateInjector
;
}
public
static
void
reset
()
{
classMap
.
clear
();
classTable
.
clear
();
delegate
=
null
;
}
}
apollo-client/src/test/java/com/ctrip/framework/apollo/integration/ConfigIntegrationTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.integration
;
import
com.google.common.base.Joiner
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.util.concurrent.SettableFuture
;
import
com.ctrip.framework.apollo.BaseIntegrationTest
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfig
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.internals.RemoteConfigLongPollService
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
org.eclipse.jetty.server.Request
;
import
org.eclipse.jetty.server.handler.AbstractHandler
;
import
org.eclipse.jetty.server.handler.ContextHandler
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
static
org
.
hamcrest
.
core
.
IsEqual
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.io.File
;
import
java.io.FileOutputStream
;
...
...
@@ -39,10 +19,30 @@ import javax.servlet.ServletException;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
static
org
.
hamcrest
.
core
.
IsEqual
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.eclipse.jetty.server.Request
;
import
org.eclipse.jetty.server.handler.AbstractHandler
;
import
org.eclipse.jetty.server.handler.ContextHandler
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
com.ctrip.framework.apollo.BaseIntegrationTest
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.build.ApolloInjector
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfig
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.internals.RemoteConfigLongPollService
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.google.common.base.Joiner
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.util.concurrent.SettableFuture
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
@@ -66,7 +66,7 @@ public class ConfigIntegrationTest extends BaseIntegrationTest {
configDir
.
delete
();
}
configDir
.
mkdirs
();
remoteConfigLongPollService
=
lookup
(
RemoteConfigLongPollService
.
class
);
remoteConfigLongPollService
=
ApolloInjector
.
getInstance
(
RemoteConfigLongPollService
.
class
);
}
@Override
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
static
org
.
hamcrest
.
core
.
IsEqual
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
java.util.Set
;
import
org.junit.Before
;
import
org.junit.Test
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.spi.ConfigFactory
;
import
com.ctrip.framework.apollo.spi.ConfigFactoryManager
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.util.Set
;
import
static
org
.
hamcrest
.
core
.
IsEqual
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
DefaultConfigManagerTest
extends
ComponentTestCase
{
public
class
DefaultConfigManagerTest
{
private
DefaultConfigManager
defaultConfigManager
;
private
static
String
someConfigContent
;
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
(
);
defineComponent
(
ConfigFactoryManager
.
class
,
MockConfigFactoryManager
.
class
);
defaultConfigManager
=
(
DefaultConfigManager
)
lookup
(
ConfigManager
.
class
);
MockInjector
.
reset
();
MockInjector
.
setInstance
(
ConfigFactoryManager
.
class
,
new
MockConfigFactoryManager
()
);
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
ConfigUtil
()
);
defaultConfigManager
=
new
DefaultConfigManager
(
);
someConfigContent
=
"someContent"
;
}
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.base.Charsets
;
import
com.google.common.base.Joiner
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.io.Files
;
import
com.google.common.util.concurrent.SettableFuture
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.io.File
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.enums.PropertyChangeType
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.io.File
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.google.common.base.Charsets
;
import
com.google.common.base.Joiner
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.io.Files
;
import
com.google.common.util.concurrent.SettableFuture
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
DefaultConfigTest
extends
ComponentTestCase
{
public
class
DefaultConfigTest
{
private
File
someResourceDir
;
private
String
someNamespace
;
private
ConfigRepository
configRepository
;
...
...
@@ -43,9 +42,8 @@ public class DefaultConfigTest extends ComponentTestCase {
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
defineComponent
(
ConfigUtil
.
class
,
MockConfigUtil
.
class
);
MockInjector
.
reset
();
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
MockConfigUtil
());
someResourceDir
=
new
File
(
ClassLoaderUtil
.
getClassPath
()
+
"/META-INF/config"
);
someResourceDir
.
mkdirs
();
...
...
@@ -55,7 +53,6 @@ public class DefaultConfigTest extends ComponentTestCase {
@After
public
void
tearDown
()
throws
Exception
{
super
.
tearDown
();
recursiveDelete
(
someResourceDir
);
}
...
...
@@ -197,7 +194,7 @@ public class DefaultConfigTest extends ComponentTestCase {
Integer
someDefaultValue
=
-
1
;
defineComponent
(
ConfigUtil
.
class
,
MockConfigUtilWithSmallCache
.
class
);
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
MockConfigUtilWithSmallCache
()
);
//set up config repo
someProperties
=
mock
(
Properties
.
class
);
...
...
@@ -230,7 +227,7 @@ public class DefaultConfigTest extends ComponentTestCase {
Integer
someDefaultValue
=
-
1
;
defineComponent
(
ConfigUtil
.
class
,
MockConfigUtilWithShortExpireTime
.
class
);
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
MockConfigUtilWithShortExpireTime
()
);
//set up config repo
someProperties
=
mock
(
Properties
.
class
);
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.util.Properties
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -9,13 +14,8 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.base.Charsets
;
import
com.google.common.base.Joiner
;
import
com.google.common.io.Files
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.ArgumentCaptor
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.Properties
;
import
static
org
.
hamcrest
.
core
.
IsEqual
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
...
...
@@ -27,10 +9,27 @@ import static org.mockito.Mockito.times;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.Properties
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.ArgumentCaptor
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.google.common.base.Charsets
;
import
com.google.common.base.Joiner
;
import
com.google.common.io.Files
;
/**
* Created by Jason on 4/9/16.
*/
public
class
LocalFileConfigRepositoryTest
extends
ComponentTestCase
{
public
class
LocalFileConfigRepositoryTest
{
private
File
someBaseDir
;
private
String
someNamespace
;
private
ConfigRepository
upstreamRepo
;
...
...
@@ -42,8 +41,6 @@ public class LocalFileConfigRepositoryTest extends ComponentTestCase {
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
someBaseDir
=
new
File
(
"src/test/resources/config-cache"
);
someBaseDir
.
mkdir
();
...
...
@@ -55,12 +52,12 @@ public class LocalFileConfigRepositoryTest extends ComponentTestCase {
upstreamRepo
=
mock
(
ConfigRepository
.
class
);
when
(
upstreamRepo
.
getConfig
()).
thenReturn
(
someProperties
);
defineComponent
(
ConfigUtil
.
class
,
MockConfigUtil
.
class
);
MockInjector
.
reset
();
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
MockConfigUtil
());
}
@After
public
void
tearDown
()
throws
Exception
{
super
.
tearDown
();
recursiveDelete
(
someBaseDir
);
}
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.util.Properties
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -8,13 +14,7 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
com.google.common.util.concurrent.SettableFuture
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
javax.servlet.http.HttpServletResponse
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -20,36 +26,30 @@ import org.mockito.invocation.InvocationOnMock;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.mockito.stubbing.Answer
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
javax.servlet.http.HttpServletResponse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
com.google.common.util.concurrent.SettableFuture
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
RemoteConfigLongPollServiceTest
extends
ComponentTestCase
{
public
class
RemoteConfigLongPollServiceTest
{
private
RemoteConfigLongPollService
remoteConfigLongPollService
;
@Mock
private
HttpResponse
<
List
<
ApolloConfigNotification
>>
pollResponse
;
@Mock
private
HttpUtil
httpUtil
;
@Mock
private
ConfigServiceLocator
configServiceLocator
;
private
Type
responseType
;
private
static
String
someServerUrl
;
...
...
@@ -58,15 +58,19 @@ public class RemoteConfigLongPollServiceTest extends ComponentTestCase {
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
MockInjector
.
reset
();
MockInjector
.
setInstance
(
HttpUtil
.
class
,
httpUtil
);
ServiceDTO
serviceDTO
=
mock
(
ServiceDTO
.
class
);
when
(
serviceDTO
.
getHomepageUrl
()).
thenReturn
(
someServerUrl
);
when
(
configServiceLocator
.
getConfigServices
()).
thenReturn
(
Lists
.
newArrayList
(
serviceDTO
));
MockInjector
.
setInstance
(
ConfigServiceLocator
.
class
,
configServiceLocator
);
defineComponent
(
ConfigUtil
.
class
,
MockConfigUtil
.
class
);
defineComponent
(
ConfigServiceLocator
.
class
,
MockConfigServiceLocator
.
class
);
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
MockConfigUtil
());
remoteConfigLongPollService
=
lookup
(
RemoteConfigLongPollService
.
class
);
remoteConfigLongPollService
=
new
RemoteConfigLongPollService
(
);
ReflectionTestUtils
.
setField
(
remoteConfigLongPollService
,
"m_httpUtil"
,
httpUtil
);
responseType
=
(
Type
)
ReflectionTestUtils
.
getField
(
remoteConfigLongPollService
,
"m_responseType"
);
...
...
@@ -365,18 +369,4 @@ public class RemoteConfigLongPollServiceTest extends ComponentTestCase {
}
}
public
static
class
MockConfigServiceLocator
extends
ConfigServiceLocator
{
@Override
public
List
<
ServiceDTO
>
getConfigServices
()
{
ServiceDTO
serviceDTO
=
mock
(
ServiceDTO
.
class
);
when
(
serviceDTO
.
getHomepageUrl
()).
thenReturn
(
someServerUrl
);
return
Lists
.
newArrayList
(
serviceDTO
);
}
@Override
public
void
initialize
()
throws
InitializationException
{
//do nothing
}
}
}
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.util.concurrent.SettableFuture
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
any
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfig
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.HttpServletResponse
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -23,31 +26,26 @@ import org.mockito.Mock;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.mockito.stubbing.Answer
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.HttpServletResponse
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
any
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfig
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.http.HttpRequest
;
import
com.ctrip.framework.apollo.util.http.HttpResponse
;
import
com.ctrip.framework.apollo.util.http.HttpUtil
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.util.concurrent.SettableFuture
;
/**
* Created by Jason on 4/9/16.
*/
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
RemoteConfigRepositoryTest
extends
ComponentTestCase
{
public
class
RemoteConfigRepositoryTest
{
@Mock
private
ConfigServiceLocator
configServiceLocator
;
private
String
someNamespace
;
...
...
@@ -59,17 +57,26 @@ public class RemoteConfigRepositoryTest extends ComponentTestCase {
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
someNamespace
=
"someName"
;
when
(
pollResponse
.
getStatusCode
()).
thenReturn
(
HttpServletResponse
.
SC_NOT_MODIFIED
);
defineComponent
(
ConfigUtil
.
class
,
MockConfigUtil
.
class
);
defineComponent
(
ConfigServiceLocator
.
class
,
MockConfigServiceLocator
.
class
);
defineComponent
(
HttpUtil
.
class
,
MockHttpUtil
.
class
);
MockInjector
.
reset
();
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
MockConfigUtil
());
String
someServerUrl
=
"http://someServer"
;
ServiceDTO
serviceDTO
=
mock
(
ServiceDTO
.
class
);
remoteConfigLongPollService
=
lookup
(
RemoteConfigLongPollService
.
class
);
when
(
serviceDTO
.
getHomepageUrl
()).
thenReturn
(
someServerUrl
);
when
(
configServiceLocator
.
getConfigServices
()).
thenReturn
(
Lists
.
newArrayList
(
serviceDTO
));
MockInjector
.
setInstance
(
ConfigServiceLocator
.
class
,
configServiceLocator
);
MockInjector
.
setInstance
(
HttpUtil
.
class
,
new
MockHttpUtil
());
remoteConfigLongPollService
=
new
RemoteConfigLongPollService
();
MockInjector
.
setInstance
(
RemoteConfigLongPollService
.
class
,
remoteConfigLongPollService
);
}
@Test
...
...
@@ -245,23 +252,6 @@ public class RemoteConfigRepositoryTest extends ComponentTestCase {
}
}
public
static
class
MockConfigServiceLocator
extends
ConfigServiceLocator
{
@Override
public
List
<
ServiceDTO
>
getConfigServices
()
{
String
someServerUrl
=
"http://someServer"
;
ServiceDTO
serviceDTO
=
mock
(
ServiceDTO
.
class
);
when
(
serviceDTO
.
getHomepageUrl
()).
thenReturn
(
someServerUrl
);
return
Lists
.
newArrayList
(
serviceDTO
);
}
@Override
public
void
initialize
()
throws
InitializationException
{
//do nothing
}
}
public
static
class
MockHttpUtil
extends
HttpUtil
{
@Override
public
<
T
>
HttpResponse
<
T
>
doGet
(
HttpRequest
httpRequest
,
Class
<
T
>
responseType
)
{
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.util.concurrent.SettableFuture
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.enums.PropertyChangeType
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -15,11 +12,13 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.enums.PropertyChangeType
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.util.concurrent.SettableFuture
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.internals
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.util.Properties
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -9,13 +14,8 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spi
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.unidal.lookup.ComponentTestCase
;
import
static
org
.
hamcrest
.
core
.
IsEqual
.
equalTo
;
import
static
org
.
hamcrest
.
core
.
IsInstanceOf
.
instanceOf
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
org.junit.Before
;
import
org.junit.Test
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
DefaultConfigFactoryManagerTest
extends
ComponentTestCase
{
public
class
DefaultConfigFactoryManagerTest
{
private
DefaultConfigFactoryManager
defaultConfigFactoryManager
;
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
defineComponent
(
ConfigRegistry
.
class
,
MockConfigRegistry
.
class
);
defaultConfigFactoryManager
=
(
DefaultConfigFactoryManager
)
lookup
(
ConfigFactoryManager
.
class
);
MockInjector
.
reset
();
MockInjector
.
setInstance
(
ConfigRegistry
.
class
,
new
MockConfigRegistry
());
defaultConfigFactoryManager
=
new
DefaultConfigFactoryManager
();
}
@Test
...
...
@@ -39,7 +37,7 @@ public class DefaultConfigFactoryManagerTest extends ComponentTestCase {
@Test
public
void
testGetFactoryFromNamespace
()
throws
Exception
{
String
someNamespace
=
"someName"
;
defineComponent
(
ConfigFactory
.
class
,
someNamespace
,
SomeConfigFactory
.
class
);
MockInjector
.
setInstance
(
ConfigFactory
.
class
,
someNamespace
,
new
SomeConfigFactory
()
);
ConfigFactory
result
=
defaultConfigFactoryManager
.
getFactory
(
someNamespace
);
...
...
@@ -50,7 +48,7 @@ public class DefaultConfigFactoryManagerTest extends ComponentTestCase {
@Test
public
void
testGetFactoryFromNamespaceMultipleTimes
()
throws
Exception
{
String
someNamespace
=
"someName"
;
defineComponent
(
ConfigFactory
.
class
,
someNamespace
,
SomeConfigFactory
.
class
);
MockInjector
.
setInstance
(
ConfigFactory
.
class
,
someNamespace
,
new
SomeConfigFactory
()
);
ConfigFactory
result
=
defaultConfigFactoryManager
.
getFactory
(
someNamespace
);
ConfigFactory
anotherResult
=
defaultConfigFactoryManager
.
getFactory
(
someNamespace
);
...
...
@@ -63,7 +61,7 @@ public class DefaultConfigFactoryManagerTest extends ComponentTestCase {
@Test
public
void
testGetFactoryFromDefault
()
throws
Exception
{
String
someNamespace
=
"someName"
;
defineComponent
(
ConfigFactory
.
class
,
AnotherConfigFactory
.
class
);
MockInjector
.
setInstance
(
ConfigFactory
.
class
,
new
AnotherConfigFactory
()
);
ConfigFactory
result
=
defaultConfigFactoryManager
.
getFactory
(
someNamespace
);
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spi
;
import
static
org
.
hamcrest
.
core
.
Is
.
is
;
import
static
org
.
hamcrest
.
core
.
IsInstanceOf
.
instanceOf
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.util.Properties
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.internals.DefaultConfig
;
...
...
@@ -13,39 +30,21 @@ import com.ctrip.framework.apollo.internals.YamlConfigFile;
import
com.ctrip.framework.apollo.internals.YmlConfigFile
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.util.Properties
;
import
static
org
.
hamcrest
.
core
.
Is
.
is
;
import
static
org
.
hamcrest
.
core
.
IsInstanceOf
.
instanceOf
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
DefaultConfigFactoryTest
extends
ComponentTestCase
{
public
class
DefaultConfigFactoryTest
{
private
DefaultConfigFactory
defaultConfigFactory
;
private
static
String
someAppId
;
private
static
Env
someEnv
;
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
someAppId
=
"someId"
;
someEnv
=
Env
.
DEV
;
defineComponent
(
ConfigUtil
.
class
,
MockConfigUtil
.
class
);
defaultConfigFactory
=
spy
((
DefaultConfigFactory
)
lookup
(
ConfigFactory
.
class
));
MockInjector
.
reset
();
MockInjector
.
setInstance
(
ConfigUtil
.
class
,
new
MockConfigUtil
());
defaultConfigFactory
=
spy
(
new
DefaultConfigFactory
());
}
@Test
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spi
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileForm
at
;
import
static
org
.
hamcrest
.
core
.
IsEqual
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTh
at
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.unidal.lookup.ComponentTestCase
;
import
static
org
.
hamcrest
.
core
.
IsEqual
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
DefaultConfigRegistryTest
extends
ComponentTestCase
{
public
class
DefaultConfigRegistryTest
{
private
DefaultConfigRegistry
defaultConfigRegistry
;
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
defaultConfigRegistry
=
(
DefaultConfigRegistry
)
lookup
(
ConfigRegistry
.
class
);
MockInjector
.
reset
();
defaultConfigRegistry
=
new
DefaultConfigRegistry
();
}
@Test
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring
;
import
com.google.common.collect.Maps
;
import
java.lang.reflect.Method
;
import
java.util.Map
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.springframework.util.ReflectionUtils
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigFile
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.build.MockInjector
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.internals.ConfigManager
;
import
com.ctrip.framework.apollo.spring.config.PropertySourcesProcessor
;
import
org.codehaus.plexus.PlexusContainer
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.springframework.util.ReflectionUtils
;
import
org.unidal.lookup.ComponentTestCase
;
import
java.lang.reflect.Method
;
import
java.util.Map
;
import
com.google.common.collect.Maps
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
abstract
class
AbstractSpringIntegrationTest
extends
ComponentTestCase
{
public
abstract
class
AbstractSpringIntegrationTest
{
private
static
final
Map
<
String
,
Config
>
CONFIG_REGISTRY
=
Maps
.
newHashMap
();
private
static
Method
PROPERTY_SOURCES_PROCESSOR_CLEAR
;
private
static
Method
CONFIG_SERVICE_
SET_CONTAINER
;
private
static
Method
CONFIG_SERVICE_
RESET
;
static
{
try
{
PROPERTY_SOURCES_PROCESSOR_CLEAR
=
PropertySourcesProcessor
.
class
.
getDeclaredMethod
(
"reset"
);
ReflectionUtils
.
makeAccessible
(
PROPERTY_SOURCES_PROCESSOR_CLEAR
);
CONFIG_SERVICE_
SET_CONTAINER
=
ConfigService
.
class
.
getDeclaredMethod
(
"setContainer"
,
PlexusContainer
.
class
);
ReflectionUtils
.
makeAccessible
(
CONFIG_SERVICE_
SET_CONTAINER
);
CONFIG_SERVICE_
RESET
=
ConfigService
.
class
.
getDeclaredMethod
(
"reset"
);
ReflectionUtils
.
makeAccessible
(
CONFIG_SERVICE_
RESET
);
}
catch
(
NoSuchMethodException
e
)
{
e
.
printStackTrace
();
}
}
@Override
@Before
public
void
setUp
()
throws
Exception
{
super
.
tearDown
();
//clear the container
super
.
setUp
();
//as PropertySourcesProcessor has some static states, so we must manually clear its state
ReflectionUtils
.
invokeMethod
(
PROPERTY_SOURCES_PROCESSOR_CLEAR
,
null
);
//as ConfigService is singleton, so we must manually clear its container
ReflectionUtils
.
invokeMethod
(
CONFIG_SERVICE_
SET_CONTAINER
,
null
,
getContainer
()
);
defineComponent
(
ConfigManager
.
class
,
MockConfigManager
.
class
);
ReflectionUtils
.
invokeMethod
(
CONFIG_SERVICE_
RESET
,
null
);
MockInjector
.
reset
();
MockInjector
.
setInstance
(
ConfigManager
.
class
,
new
MockConfigManager
()
);
}
@Override
@After
public
void
tearDown
()
throws
Exception
{
super
.
tearDown
();
CONFIG_REGISTRY
.
clear
();
}
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring
;
import
com.google.common.collect.Lists
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
java.util.List
;
import
org.junit.Test
;
import
org.mockito.invocation.InvocationOnMock
;
...
...
@@ -18,12 +15,14 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
com.google.common.collect.Lists
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -11,11 +13,9 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.stereotype.Component
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XMLConfigAnnotationTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring
;
import
com.google.common.collect.Lists
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
java.util.List
;
import
org.junit.Test
;
import
org.mockito.invocation.InvocationOnMock
;
...
...
@@ -15,12 +13,13 @@ import org.mockito.stubbing.Answer;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigChangeListener
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
com.google.common.collect.Lists
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.spring
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
org.junit.Test
;
import
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
org.junit.Test
;
import
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ExceptionUtilTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.util
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/util/parser/DateParserTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.util.parser
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Locale
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
/**
* @author Jason Song(song_s@ctrip.com)
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/util/parser/DurationParserTest.java
浏览文件 @
f048baff
package
com.ctrip.framework.apollo.util.parser
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
public
class
DurationParserTest
{
private
Parsers
.
DurationParser
durationParser
=
Parsers
.
forDuration
();
...
...
apollo-client/src/test/resources/META-INF/services/com.ctrip.framework.apollo.internals.Injector
0 → 100644
浏览文件 @
f048baff
com.ctrip.framework.apollo.build.MockInjector
\ No newline at end of file
apollo-common/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
apollo-configservice/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
apollo-core/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
apollo-demo/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<artifactId>
apollo
</artifactId>
<groupId>
com.ctrip.framework.apollo
</groupId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apollo-demo
</artifactId>
...
...
apollo-portal/pom.xml
浏览文件 @
f048baff
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
pom.xml
浏览文件 @
f048baff
...
...
@@ -5,7 +5,7 @@
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo
</artifactId>
<version>
0.
6.4
-SNAPSHOT
</version>
<version>
0.
7.0
-SNAPSHOT
</version>
<name>
Apollo
</name>
<packaging>
pom
</packaging>
<description>
Ctrip Configuration Center
</description>
...
...
@@ -263,9 +263,9 @@
<version>
5.1.39
</version>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
foundation-serv
ice
</artifactId>
<version>
2.5.6
</version>
<groupId>
com.google.inject
</groupId>
<artifactId>
gu
ice
</artifactId>
<version>
4.1.0
</version>
</dependency>
<!--for test -->
<dependency>
...
...
@@ -583,12 +583,6 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>
internal.repo
</id>
<url>
https://raw.github.com/ctripcorp/apollo/mvn-repo/
</url>
</repository>
</repositories>
</profile>
<profile>
<!-- for open source usage -->
...
...
@@ -599,12 +593,6 @@
<activation>
<activeByDefault>
true
</activeByDefault>
</activation>
<repositories>
<repository>
<id>
internal.repo
</id>
<url>
https://raw.github.com/ctripcorp/apollo/mvn-repo/
</url>
</repository>
</repositories>
</profile>
<profile>
<!-- for ctrip development -->
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录