forked from apolloconfig/apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add getPropertyNames interfact to Config
- Loading branch information
Showing
16 changed files
with
77 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
package com.ctrip.framework.apollo; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* @author Jason Song([email protected]) | ||
*/ | ||
public interface Config { | ||
/** | ||
* Return the property value with the given key, or {@code defaultValue} if the key doesn't exist. | ||
* | ||
* @param key the property name | ||
* | ||
* @param key the property name | ||
* @param defaultValue the default value when key is not found | ||
* @return the property value | ||
*/ | ||
|
@@ -16,80 +18,74 @@ public interface Config { | |
/** | ||
* Return the integer property value with the given key, or {@code defaultValue} if the key | ||
* doesn't exist. | ||
* | ||
* @param key the property name | ||
* | ||
* @param key the property name | ||
* @param defaultValue the default value when key is not found | ||
* @return the property value as integer | ||
* | ||
* @throws NumberFormatException if the property value is invalid | ||
*/ | ||
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. | ||
* | ||
* @param key the property name | ||
* | ||
* @param key the property name | ||
* @param defaultValue the default value when key is not found | ||
* @return the property value as long | ||
* | ||
* @throws NumberFormatException if the property value is invalid | ||
*/ | ||
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. | ||
* | ||
* @param key the property name | ||
* | ||
* @param key the property name | ||
* @param defaultValue the default value when key is not found | ||
* @return the property value as short | ||
* | ||
* @throws NumberFormatException if the property value is invalid | ||
*/ | ||
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. | ||
* | ||
* @param key the property name | ||
* | ||
* @param key the property name | ||
* @param defaultValue the default value when key is not found | ||
* @return the property value as float | ||
* | ||
* @throws NumberFormatException if the property value is invalid | ||
*/ | ||
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. | ||
* | ||
* @param key the property name | ||
* | ||
* @param key the property name | ||
* @param defaultValue the default value when key is not found | ||
* @return the property value as double | ||
* | ||
* @throws NumberFormatException if the property value is invalid | ||
*/ | ||
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. | ||
* | ||
* @param key the property name | ||
* | ||
* @param key the property name | ||
* @param defaultValue the default value when key is not found | ||
* @return the property value as byte | ||
* | ||
* @throws NumberFormatException if the property value is invalid | ||
*/ | ||
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. | ||
* | ||
* @param key the property name | ||
* | ||
* @param key the property name | ||
* @param defaultValue the default value when key is not found | ||
* @return the property value as boolean | ||
*/ | ||
|
@@ -98,18 +94,24 @@ public interface Config { | |
/** | ||
* 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 the delimiter regex | ||
* | ||
* @param key the property name | ||
* @param delimiter the delimiter regex | ||
* @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); | ||
|
||
/** | ||
* Return a set of the property names | ||
* | ||
* @return the property names | ||
*/ | ||
public Set<String> getPropertyNames(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,11 @@ | |
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; | ||
|
||
/** | ||
* @author Jason Song([email protected]) | ||
|
@@ -59,6 +61,15 @@ public String getProperty(String key, String defaultValue) { | |
return this.m_configProperties.getProperty(key, defaultValue); | ||
} | ||
|
||
@Override | ||
public Set<String> getPropertyNames() { | ||
if (m_configProperties == null) { | ||
return Collections.emptySet(); | ||
} | ||
|
||
return m_configProperties.stringPropertyNames(); | ||
} | ||
|
||
@Override | ||
public synchronized void onRepositoryChange(String namespace, Properties newProperties) { | ||
if (newProperties.equals(m_configProperties)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters