You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by me...@apache.org on 2019/12/13 02:47:36 UTC
[dubbo] branch 2.7.5-release updated: Polish apache/dubbo/#5470
This is an automated email from the ASF dual-hosted git repository.
mercyblitz pushed a commit to branch 2.7.5-release
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/2.7.5-release by this push:
new a63a3c3 Polish apache/dubbo/#5470
a63a3c3 is described below
commit a63a3c35b4fa667854eeb826840a1e667e5477d8
Author: mercyblitz <me...@gmail.com>
AuthorDate: Fri Dec 13 10:47:19 2019 +0800
Polish apache/dubbo/#5470
---
.../config/configcenter/DynamicConfiguration.java | 38 +++++++++++++++++-----
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/config/configcenter/DynamicConfiguration.java b/dubbo-common/src/main/java/org/apache/dubbo/common/config/configcenter/DynamicConfiguration.java
index 398ed6f..c532746 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/config/configcenter/DynamicConfiguration.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/config/configcenter/DynamicConfiguration.java
@@ -52,7 +52,7 @@ public interface DynamicConfiguration extends Configuration, AutoCloseable {
* @param listener configuration listener
*/
default void addListener(String key, ConfigurationListener listener) {
- addListener(key, DEFAULT_GROUP, listener);
+ addListener(key, getDefaultGroup(), listener);
}
@@ -63,7 +63,7 @@ public interface DynamicConfiguration extends Configuration, AutoCloseable {
* @param listener configuration listener
*/
default void removeListener(String key, ConfigurationListener listener) {
- removeListener(key, DEFAULT_GROUP, listener);
+ removeListener(key, getDefaultGroup(), listener);
}
/**
@@ -88,14 +88,15 @@ public interface DynamicConfiguration extends Configuration, AutoCloseable {
void removeListener(String key, String group, ConfigurationListener listener);
/**
- * Get the configuration mapped to the given key and the given group
+ * Get the configuration mapped to the given key and the given group with {@link #getDefaultTimeout() the default
+ * timeout}
*
* @param key the key to represent a configuration
* @param group the group where the key belongs to
* @return target configuration mapped to the given key and the given group
*/
default String getConfig(String key, String group) {
- return getConfig(key, group, -1L);
+ return getConfig(key, group, getDefaultTimeout());
}
/**
@@ -111,10 +112,11 @@ public interface DynamicConfiguration extends Configuration, AutoCloseable {
String getConfig(String key, String group, long timeout) throws IllegalStateException;
/**
- * This method are mostly used to get a compound config file, such as a complete dubbo.properties file.
+ * This method are mostly used to get a compound config file with {@link #getDefaultTimeout() the default timeout},
+ * such as a complete dubbo.properties file.
*/
default String getProperties(String key, String group) throws IllegalStateException {
- return getProperties(key, group, -1L);
+ return getProperties(key, group, getDefaultTimeout());
}
/**
@@ -127,7 +129,7 @@ public interface DynamicConfiguration extends Configuration, AutoCloseable {
}
/**
- * Publish Config mapped to the given key under the {@link #DEFAULT_GROUP default group}
+ * Publish Config mapped to the given key under the {@link #getDefaultGroup() default group}
*
* @param key the key to represent a configuration
* @param content the content of configuration
@@ -136,7 +138,7 @@ public interface DynamicConfiguration extends Configuration, AutoCloseable {
* @since 2.7.5
*/
default boolean publishConfig(String key, String content) throws UnsupportedOperationException {
- return publishConfig(key, DEFAULT_GROUP, content);
+ return publishConfig(key, getDefaultGroup(), content);
}
/**
@@ -166,6 +168,26 @@ public interface DynamicConfiguration extends Configuration, AutoCloseable {
}
/**
+ * Get the default group for the operations
+ *
+ * @return The default value is {@link #DEFAULT_GROUP "dubbo"}
+ * @since 2.7.5
+ */
+ default String getDefaultGroup() {
+ return DEFAULT_GROUP;
+ }
+
+ /**
+ * Get the default timeout for the operations in milliseconds
+ *
+ * @return The default value is <code>-1L</code>
+ * @since 2.7.5
+ */
+ default long getDefaultTimeout() {
+ return -1L;
+ }
+
+ /**
* Close the configuration
*
* @throws Exception