Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
e7d91c7d
Commit
e7d91c7d
authored
Jul 07, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change namespacePrefix to namespace
parent
3da14c8c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
32 deletions
+32
-32
ConfigService.java
...c/main/java/com/ctrip/framework/apollo/ConfigService.java
+2
-2
ConfigManager.java
...a/com/ctrip/framework/apollo/internals/ConfigManager.java
+2
-2
DefaultConfigManager.java
...trip/framework/apollo/internals/DefaultConfigManager.java
+7
-7
ConfigServiceTest.java
...st/java/com/ctrip/framework/apollo/ConfigServiceTest.java
+7
-7
DefaultConfigManagerTest.java
.../framework/apollo/internals/DefaultConfigManagerTest.java
+5
-5
ConfigControllerTest.java
...apollo/configservice/controller/ConfigControllerTest.java
+5
-5
ApolloConfigFileDemo.java
apollo-demo/src/main/java/ApolloConfigFileDemo.java
+4
-4
No files found.
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
View file @
e7d91c7d
...
...
@@ -42,8 +42,8 @@ public class ConfigService {
return
getManager
().
getConfig
(
namespace
);
}
public
static
ConfigFile
getConfigFile
(
String
namespace
Prefix
,
ConfigFileFormat
configFileFormat
)
{
return
getManager
().
getConfigFile
(
namespace
Prefix
,
configFileFormat
);
public
static
ConfigFile
getConfigFile
(
String
namespace
,
ConfigFileFormat
configFileFormat
)
{
return
getManager
().
getConfigFile
(
namespace
,
configFileFormat
);
}
private
static
ConfigManager
getManager
()
{
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java
View file @
e7d91c7d
...
...
@@ -17,9 +17,9 @@ public interface ConfigManager {
/**
* Get the config file instance for the namespace specified.
* @param namespace
Prefix
the namespace
* @param namespace the namespace
* @param configFileFormat the config file format
* @return the config file instance for the namespace
*/
public
ConfigFile
getConfigFile
(
String
namespace
Prefix
,
ConfigFileFormat
configFileFormat
);
public
ConfigFile
getConfigFile
(
String
namespace
,
ConfigFileFormat
configFileFormat
);
}
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java
View file @
e7d91c7d
...
...
@@ -45,19 +45,19 @@ public class DefaultConfigManager implements ConfigManager {
}
@Override
public
ConfigFile
getConfigFile
(
String
namespace
Prefix
,
ConfigFileFormat
configFileFormat
)
{
String
namespace
=
String
.
format
(
"%s.%s"
,
namespacePrefix
,
configFileFormat
.
getValue
());
ConfigFile
configFile
=
m_configFiles
.
get
(
namespace
);
public
ConfigFile
getConfigFile
(
String
namespace
,
ConfigFileFormat
configFileFormat
)
{
String
namespace
FileName
=
String
.
format
(
"%s.%s"
,
namespace
,
configFileFormat
.
getValue
());
ConfigFile
configFile
=
m_configFiles
.
get
(
namespace
FileName
);
if
(
configFile
==
null
)
{
synchronized
(
this
)
{
configFile
=
m_configFiles
.
get
(
namespace
);
configFile
=
m_configFiles
.
get
(
namespace
FileName
);
if
(
configFile
==
null
)
{
ConfigFactory
factory
=
m_factoryManager
.
getFactory
(
namespace
);
ConfigFactory
factory
=
m_factoryManager
.
getFactory
(
namespace
FileName
);
configFile
=
factory
.
createConfigFile
(
namespace
,
configFileFormat
);
m_configFiles
.
put
(
namespace
,
configFile
);
configFile
=
factory
.
createConfigFile
(
namespace
FileName
,
configFileFormat
);
m_configFiles
.
put
(
namespace
FileName
,
configFile
);
}
}
}
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java
View file @
e7d91c7d
...
...
@@ -65,16 +65,16 @@ public class ConfigServiceTest extends ComponentTestCase {
@Test
public
void
testMockConfigFactoryForConfigFile
()
throws
Exception
{
String
someNamespace
Prefix
=
"mock"
;
String
someNamespace
=
"mock"
;
ConfigFileFormat
someConfigFileFormat
=
ConfigFileFormat
.
Properties
;
String
someNamespace
=
String
.
format
(
"%s.%s"
,
someNamespace
Prefix
,
someConfigFileFormat
.
getValue
());
defineComponent
(
ConfigFactory
.
class
,
someNamespace
,
MockConfigFactory
.
class
);
String
someNamespace
FileName
=
String
.
format
(
"%s.%s"
,
someNamespace
,
someConfigFileFormat
.
getValue
());
defineComponent
(
ConfigFactory
.
class
,
someNamespace
FileName
,
MockConfigFactory
.
class
);
ConfigFile
configFile
=
ConfigService
.
getConfigFile
(
someNamespace
Prefix
,
someConfigFileFormat
);
ConfigFile
configFile
=
ConfigService
.
getConfigFile
(
someNamespace
,
someConfigFileFormat
);
assertEquals
(
someNamespace
,
configFile
.
getNamespace
());
assertEquals
(
someNamespace
+
":"
+
someConfigFileFormat
.
getValue
(),
configFile
.
getContent
());
assertEquals
(
someNamespace
FileName
,
configFile
.
getNamespace
());
assertEquals
(
someNamespace
FileName
+
":"
+
someConfigFileFormat
.
getValue
(),
configFile
.
getContent
());
}
private
static
class
MockConfig
extends
AbstractConfig
{
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java
View file @
e7d91c7d
...
...
@@ -56,11 +56,11 @@ public class DefaultConfigManagerTest extends ComponentTestCase {
@Test
public
void
testGetConfigFile
()
throws
Exception
{
String
someNamespace
Prefix
=
"someName"
;
String
someNamespace
=
"someName"
;
ConfigFileFormat
someConfigFileFormat
=
ConfigFileFormat
.
Properties
;
ConfigFile
configFile
=
defaultConfigManager
.
getConfigFile
(
someNamespace
Prefix
,
someConfigFileFormat
);
defaultConfigManager
.
getConfigFile
(
someNamespace
,
someConfigFileFormat
);
assertEquals
(
someConfigFileFormat
,
configFile
.
getConfigFileFormat
());
assertEquals
(
someConfigContent
,
configFile
.
getContent
());
...
...
@@ -68,13 +68,13 @@ public class DefaultConfigManagerTest extends ComponentTestCase {
@Test
public
void
testGetConfigFileMultipleTimesWithSameNamespace
()
throws
Exception
{
String
someNamespace
Prefix
=
"someName"
;
String
someNamespace
=
"someName"
;
ConfigFileFormat
someConfigFileFormat
=
ConfigFileFormat
.
Properties
;
ConfigFile
someConfigFile
=
defaultConfigManager
.
getConfigFile
(
someNamespace
Prefix
,
someConfigFileFormat
);
defaultConfigManager
.
getConfigFile
(
someNamespace
,
someConfigFileFormat
);
ConfigFile
anotherConfigFile
=
defaultConfigManager
.
getConfigFile
(
someNamespace
Prefix
,
someConfigFileFormat
);
defaultConfigManager
.
getConfigFile
(
someNamespace
,
someConfigFileFormat
);
assertThat
(
"Get config file multiple times with the same namespace should return the same config file instance"
,
...
...
apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/ConfigControllerTest.java
View file @
e7d91c7d
...
...
@@ -131,16 +131,16 @@ public class ConfigControllerTest {
public
void
testQueryConfigFileWithPrivateNamespace
()
throws
Exception
{
String
someClientSideReleaseKey
=
"1"
;
String
someServerSideNewReleaseKey
=
"2"
;
String
somePrivateNamespace
Prefix
=
"datasource"
;
String
somePrivateNamespace
=
"datasource"
;
HttpServletResponse
someResponse
=
mock
(
HttpServletResponse
.
class
);
String
somePrivateNamespaceName
=
String
.
format
(
"%s.%s"
,
somePrivateNamespace
Prefix
,
"xml"
);
String
somePrivateNamespaceName
=
String
.
format
(
"%s.%s"
,
somePrivateNamespace
,
"xml"
);
AppNamespace
appNamespace
=
mock
(
AppNamespace
.
class
);
when
(
configService
.
findRelease
(
someAppId
,
someClusterName
,
somePrivateNamespace
Prefix
))
when
(
configService
.
findRelease
(
someAppId
,
someClusterName
,
somePrivateNamespace
))
.
thenReturn
(
someRelease
);
when
(
someRelease
.
getReleaseKey
()).
thenReturn
(
someServerSideNewReleaseKey
);
when
(
namespaceUtil
.
filterNamespaceName
(
somePrivateNamespaceName
)).
thenReturn
(
somePrivateNamespace
Prefix
);
when
(
appNamespaceService
.
findOne
(
someAppId
,
somePrivateNamespace
Prefix
))
when
(
namespaceUtil
.
filterNamespaceName
(
somePrivateNamespaceName
)).
thenReturn
(
somePrivateNamespace
);
when
(
appNamespaceService
.
findOne
(
someAppId
,
somePrivateNamespace
))
.
thenReturn
(
appNamespace
);
ApolloConfig
result
=
configController
.
queryConfig
(
someAppId
,
someClusterName
,
...
...
apollo-demo/src/main/java/ApolloConfigFileDemo.java
View file @
e7d91c7d
...
...
@@ -15,18 +15,18 @@ import java.io.InputStreamReader;
public
class
ApolloConfigFileDemo
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApolloConfigDemo
.
class
);
private
ConfigFile
configFile
;
private
String
namespace
Prefix
=
"application"
;
private
String
namespace
=
"application"
;
public
ApolloConfigFileDemo
()
{
configFile
=
ConfigService
.
getConfigFile
(
namespace
Prefix
,
ConfigFileFormat
.
XML
);
configFile
=
ConfigService
.
getConfigFile
(
namespace
,
ConfigFileFormat
.
XML
);
}
private
void
print
()
{
if
(!
configFile
.
hasContent
())
{
System
.
out
.
println
(
"No config file content found for "
+
namespace
Prefix
);
System
.
out
.
println
(
"No config file content found for "
+
namespace
);
return
;
}
System
.
out
.
println
(
"=== Config File Content for "
+
namespace
Prefix
+
" is as follows: "
);
System
.
out
.
println
(
"=== Config File Content for "
+
namespace
+
" is as follows: "
);
System
.
out
.
println
(
configFile
.
getContent
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment