接口 DynamicConfiguration
-
- 所有超级接口:
AutoCloseable,Configuration
- 所有已知实现类:
AbstractDynamicConfiguration,CompositeDynamicConfiguration,FileSystemDynamicConfiguration,NopDynamicConfiguration,TreePathDynamicConfiguration
public interface DynamicConfiguration extends Configuration, AutoCloseable
Dynamic Configuration
From the use scenario internally inside framework, there're mainly three kinds of methods:getProperties(String, String, long), get configuration file from Config Center at start up.addListener(String, String, ConfigurationListener)/removeListener(String, String, ConfigurationListener), add or remove listeners for governance rules or config items that need to watch.Configuration.getProperty(String, Object), get a single config item.getConfig(String, String, long), get the specified config
-
-
字段概要
字段 修饰符和类型 字段 说明 static StringDEFAULT_GROUP
-
方法概要
所有方法 静态方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 voidaddListener(String key, String group, ConfigurationListener listener)Register a configuration listener for a specified key The listener only works for service governance purpose, so the target group would always be the value user specifies at startup or 'dubbo' by default.default voidaddListener(String key, ConfigurationListener listener)default voidclose()Close the configurationdefault StringgetConfig(String key, String group)Get the configuration mapped to the given key and the given group withthe default timeoutStringgetConfig(String key, String group, long timeout)Get the configuration mapped to the given key and the given group.default SortedSet<String>getConfigKeys(String group)Get the config keys by the specified groupdefault StringgetDefaultGroup()Get the default group for the operationsdefault longgetDefaultTimeout()Get the default timeout for the operations in millisecondsstatic DynamicConfigurationgetDynamicConfiguration()Find DynamicConfiguration instancestatic DynamicConfigurationgetDynamicConfiguration(URL connectionURL)Get the instance ofDynamicConfigurationby the specified connectionURLdefault StringgetProperties(String key, String group)This method are mostly used to get a compound config file withthe default timeout, such as a complete dubbo.properties file.default StringgetProperties(String key, String group, long timeout)This method are mostly used to get a compound config file, such as a complete dubbo.properties file.static StringgetRuleKey(URL url)The format is '{interfaceName}:[version]:[group]'default booleanpublishConfig(String key, String content)Publish Config mapped to the given key under thedefault groupdefault booleanpublishConfig(String key, String group, String content)Publish Config mapped to the given key and the given group.default booleanremoveConfig(String key, String group)voidremoveListener(String key, String group, ConfigurationListener listener)Stops one listener from listening to value changes in the specified key.default voidremoveListener(String key, ConfigurationListener listener)-
从接口继承的方法 org.apache.dubbo.common.config.Configuration
containsKey, convert, getBoolean, getBoolean, getBoolean, getInt, getInt, getInteger, getInternalProperty, getProperty, getProperty, getString, getString
-
-
-
-
方法详细资料
-
addListener
default void addListener(String key, ConfigurationListener listener)
- 参数:
key- the key to represent a configurationlistener- configuration listener
-
removeListener
default void removeListener(String key, ConfigurationListener listener)
- 参数:
key- the key to represent a configurationlistener- configuration listener
-
addListener
void addListener(String key, String group, ConfigurationListener listener)
Register a configuration listener for a specified key The listener only works for service governance purpose, so the target group would always be the value user specifies at startup or 'dubbo' by default. This method will only register listener, which means it will not trigger a notification that contains the current value.- 参数:
key- the key to represent a configurationgroup- the group where the key belongs tolistener- configuration listener
-
removeListener
void removeListener(String key, String group, ConfigurationListener listener)
Stops one listener from listening to value changes in the specified key.- 参数:
key- the key to represent a configurationgroup- the group where the key belongs tolistener- configuration listener
-
getConfig
default String getConfig(String key, String group)
Get the configuration mapped to the given key and the given group withthe default timeout- 参数:
key- the key to represent a configurationgroup- the group where the key belongs to- 返回:
- target configuration mapped to the given key and the given group
-
getConfig
String getConfig(String key, String group, long timeout) throws IllegalStateException
Get the configuration mapped to the given key and the given group. If the configuration fails to fetch after timeout exceeds, IllegalStateException will be thrown.- 参数:
key- the key to represent a configurationgroup- the group where the key belongs totimeout- timeout value for fetching the target config- 返回:
- target configuration mapped to the given key and the given group, IllegalStateException will be thrown if timeout exceeds.
- 抛出:
IllegalStateException
-
getProperties
default String getProperties(String key, String group) throws IllegalStateException
This method are mostly used to get a compound config file withthe default timeout, such as a complete dubbo.properties file.
-
getProperties
default String getProperties(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.
-
publishConfig
default boolean publishConfig(String key, String content) throws UnsupportedOperationException
Publish Config mapped to the given key under thedefault group- 参数:
key- the key to represent a configurationcontent- the content of configuration- 返回:
trueif success, orfalse- 抛出:
UnsupportedOperationException- If the under layer does not support- 从以下版本开始:
- 2.7.5
-
publishConfig
default boolean publishConfig(String key, String group, String content) throws UnsupportedOperationException
Publish Config mapped to the given key and the given group.- 参数:
key- the key to represent a configurationgroup- the group where the key belongs tocontent- the content of configuration- 返回:
trueif success, orfalse- 抛出:
UnsupportedOperationException- If the under layer does not support- 从以下版本开始:
- 2.7.5
-
getConfigKeys
default SortedSet<String> getConfigKeys(String group) throws UnsupportedOperationException
Get the config keys by the specified group- 参数:
group- the specified group- 返回:
- the read-only non-null sorted
setof config keys - 抛出:
UnsupportedOperationException- If the under layer does not support- 从以下版本开始:
- 2.7.5
-
getDefaultGroup
default String getDefaultGroup()
Get the default group for the operations- 返回:
- The default value is
"dubbo" - 从以下版本开始:
- 2.7.5
-
getDefaultTimeout
default long getDefaultTimeout()
Get the default timeout for the operations in milliseconds- 返回:
- The default value is
-1L - 从以下版本开始:
- 2.7.5
-
close
default void close() throws ExceptionClose the configuration- 指定者:
close在接口中AutoCloseable- 抛出:
Exception- 从以下版本开始:
- 2.7.5
-
getDynamicConfiguration
static DynamicConfiguration getDynamicConfiguration()
Find DynamicConfiguration instance- 返回:
- DynamicConfiguration instance
-
getDynamicConfiguration
static DynamicConfiguration getDynamicConfiguration(URL connectionURL)
Get the instance ofDynamicConfigurationby the specified connectionURL- 参数:
connectionURL-- 返回:
- non-null
- 从以下版本开始:
- 2.7.5
-
-