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
54c084f2
Commit
54c084f2
authored
May 18, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init client readme
parent
501aba1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
README.md
apollo-client/README.md
+41
-0
No files found.
apollo-client/README.md
0 → 100644
View file @
54c084f2
## Maven Dependency
<dependency>
<groupId>
com.ctrip.apollo
</groupId>
<artifactId>
apollo-client
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
</dependency>
## Client Usage
### 1. Load config from default namespace(application)
```
java
Config
config
=
ConfigService
.
getAppConfig
();
String
someKey
=
"someKeyFromDefaultNamespace"
;
String
someDefaultValue
=
"someDefaultValueForTheKey"
;
System
.
out
.
println
(
config
.
getProperty
(
someKey
,
someDefaultValue
));
```
### 2. Register config change listener
```
java
Config
config
=
ConfigService
.
getAppConfig
();
config
.
addChangeListener
(
new
ConfigChangeListener
()
{
@Override
public
void
onChange
(
ConfigChangeEvent
changeEvent
)
{
System
.
out
.
println
(
"Changes for namespace "
+
changeEvent
.
getNamespace
());
for
(
String
key
:
changeEvent
.
changedKeys
())
{
ConfigChange
change
=
changeEvent
.
getChange
(
key
);
System
.
out
.
println
(
String
.
format
(
"Change - key: %s, oldValue: %s, newValue: %s, changeType: %s"
,
change
.
getPropertyName
(),
change
.
getOldValue
(),
change
.
getNewValue
(),
change
.
getChangeType
()));
}
}
});
```
### 3. Load config from public namespace
```
java
String
somePublicNamespace
=
"CAT"
;
Config
config
=
ConfigService
.
getConfig
(
somePublicNamespace
);
String
someKey
=
"someKeyFromPublicNamespace"
;
String
someDefaultValue
=
"someDefaultValueForTheKey"
;
System
.
out
.
println
(
config
.
getProperty
(
someKey
,
someDefaultValue
));
```
\ No newline at end of file
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