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
a0308f8d
Commit
a0308f8d
authored
May 25, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #219 from yiming187/client_update
Add get array property interface in client
parents
9dfb8dcc
8abbac63
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
30 deletions
+53
-30
Config.java
...ient/src/main/java/com/ctrip/framework/apollo/Config.java
+43
-24
AbstractConfig.java
.../com/ctrip/framework/apollo/internals/AbstractConfig.java
+10
-6
No files found.
apollo-client/src/main/java/com/ctrip/framework/apollo/Config.java
View file @
a0308f8d
...
...
@@ -5,19 +5,20 @@ package com.ctrip.framework.apollo;
*/
public
interface
Config
{
/**
* Return the property value with the given key, or
*
{@code defaultValue} if the key doesn't exist.
* Return the property value with the given key, or
{@code defaultValue} if the key doesn't exist.
*
* @param key the property name
* @param defaultValue the default value
is
key is not found
* @param defaultValue the default value
when
key is not found
* @return the property value
*/
public
String
getProperty
(
String
key
,
String
defaultValue
);
/**
* Return the integer property value with the given key, or
* {@code defaultValue} if the key doesn't exist.
* Return the integer property value with the given key, or {@code defaultValue} if the key
* doesn't exist.
*
* @param key the property name
* @param defaultValue the default value
is
key is not found
* @param defaultValue the default value
when
key is not found
* @return the property value as integer
*
* @throws NumberFormatException if the property value is invalid
...
...
@@ -25,10 +26,11 @@ public interface Config {
public
Integer
getIntProperty
(
String
key
,
Integer
defaultValue
);
/**
* Return the long property value with the given key, or
* {@code defaultValue} if the key doesn't exist.
* Return the long property value with the given key, or {@code defaultValue} if the key doesn't
* exist.
*
* @param key the property name
* @param defaultValue the default value
is
key is not found
* @param defaultValue the default value
when
key is not found
* @return the property value as long
*
* @throws NumberFormatException if the property value is invalid
...
...
@@ -36,10 +38,11 @@ public interface Config {
public
Long
getLongProperty
(
String
key
,
Long
defaultValue
);
/**
* Return the short property value with the given key, or
* {@code defaultValue} if the key doesn't exist.
* Return the short property value with the given key, or {@code defaultValue} if the key doesn't
* exist.
*
* @param key the property name
* @param defaultValue the default value
is
key is not found
* @param defaultValue the default value
when
key is not found
* @return the property value as short
*
* @throws NumberFormatException if the property value is invalid
...
...
@@ -47,10 +50,11 @@ public interface Config {
public
Short
getShortProperty
(
String
key
,
Short
defaultValue
);
/**
* Return the float property value with the given key, or
* {@code defaultValue} if the key doesn't exist.
* Return the float property value with the given key, or {@code defaultValue} if the key doesn't
* exist.
*
* @param key the property name
* @param defaultValue the default value
is
key is not found
* @param defaultValue the default value
when
key is not found
* @return the property value as float
*
* @throws NumberFormatException if the property value is invalid
...
...
@@ -58,10 +62,11 @@ public interface Config {
public
Float
getFloatProperty
(
String
key
,
Float
defaultValue
);
/**
* Return the double property value with the given key, or
* {@code defaultValue} if the key doesn't exist.
* Return the double property value with the given key, or {@code defaultValue} if the key doesn't
* exist.
*
* @param key the property name
* @param defaultValue the default value
is
key is not found
* @param defaultValue the default value
when
key is not found
* @return the property value as double
*
* @throws NumberFormatException if the property value is invalid
...
...
@@ -69,10 +74,11 @@ public interface Config {
public
Double
getDoubleProperty
(
String
key
,
Double
defaultValue
);
/**
* Return the byte property value with the given key, or
* {@code defaultValue} if the key doesn't exist.
* Return the byte property value with the given key, or {@code defaultValue} if the key doesn't
* exist.
*
* @param key the property name
* @param defaultValue the default value
is
key is not found
* @param defaultValue the default value
when
key is not found
* @return the property value as byte
*
* @throws NumberFormatException if the property value is invalid
...
...
@@ -80,16 +86,29 @@ public interface Config {
public
Byte
getByteProperty
(
String
key
,
Byte
defaultValue
);
/**
* Return the boolean property value with the given key, or
* {@code defaultValue} if the key doesn't exist.
* Return the boolean property value with the given key, or {@code defaultValue} if the key
* doesn't exist.
*
* @param key the property name
* @param defaultValue the default value
is
key is not found
* @param defaultValue the default value
when
key is not found
* @return the property value as boolean
*/
public
Boolean
getBooleanProperty
(
String
key
,
Boolean
defaultValue
);
/**
* Return the array property value with the given key, or {@code defaultValue} if the key doesn't
* exist.
*
* @param key the property name
* @param delimiter
* @param defaultValue the default value when key is not found
* @return
*/
public
String
[]
getArrayProperty
(
String
key
,
String
delimiter
,
String
[]
defaultValue
);
/**
* Add change listener to this config instance.
*
* @param listener the config change listener
*/
public
void
addChangeListener
(
ConfigChangeListener
listener
);
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java
View file @
a0308f8d
...
...
@@ -74,6 +74,12 @@ public abstract class AbstractConfig implements Config {
return
value
==
null
?
defaultValue
:
Boolean
.
parseBoolean
(
value
);
}
@Override
public
String
[]
getArrayProperty
(
String
key
,
String
delimiter
,
String
[]
defaultValue
)
{
String
value
=
getProperty
(
key
,
null
);
return
value
==
null
?
defaultValue
:
value
.
split
(
delimiter
);
}
protected
void
fireConfigChange
(
ConfigChangeEvent
changeEvent
)
{
for
(
ConfigChangeListener
listener
:
m_listeners
)
{
try
{
...
...
@@ -85,8 +91,7 @@ public abstract class AbstractConfig implements Config {
}
}
List
<
ConfigChange
>
calcPropertyChanges
(
String
namespace
,
Properties
previous
,
List
<
ConfigChange
>
calcPropertyChanges
(
String
namespace
,
Properties
previous
,
Properties
current
)
{
if
(
previous
==
null
)
{
previous
=
new
Properties
();
...
...
@@ -106,8 +111,7 @@ public abstract class AbstractConfig implements Config {
List
<
ConfigChange
>
changes
=
Lists
.
newArrayList
();
for
(
String
newKey
:
newKeys
)
{
changes
.
add
(
new
ConfigChange
(
namespace
,
newKey
,
null
,
current
.
getProperty
(
newKey
),
changes
.
add
(
new
ConfigChange
(
namespace
,
newKey
,
null
,
current
.
getProperty
(
newKey
),
PropertyChangeType
.
ADDED
));
}
...
...
@@ -122,8 +126,8 @@ public abstract class AbstractConfig implements Config {
if
(
Objects
.
equal
(
previousValue
,
currentValue
))
{
continue
;
}
changes
.
add
(
new
ConfigChange
(
namespace
,
commonKey
,
previousValue
,
currentValue
,
PropertyChangeType
.
MODIFIED
));
changes
.
add
(
new
ConfigChange
(
namespace
,
commonKey
,
previousValue
,
currentValue
,
PropertyChangeType
.
MODIFIED
));
}
return
changes
;
...
...
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