Interface DynamicConfiguration
- All Superinterfaces:
AutoCloseable,Configuration
- All Known Implementing Classes:
AbstractDynamicConfiguration,CompositeDynamicConfiguration,NopDynamicConfiguration,TreePathDynamicConfiguration
Dynamic Configuration
From the use scenario internally inside framework, there are mainly three kinds of methods:
From the use scenario internally inside framework, there are 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
- See Also:
-
Field Summary
FieldsFields inherited from interface org.apache.dubbo.common.config.Configuration
interfaceLevelLogger -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(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 StringGet the configuration mapped to the given key and the given group withthe default timeoutGet the configuration mapped to the given key and the given group.default ConfigItemgetConfigItem(String key, String group) get configItem which contains content and stat info.default StringGet the default group for the operationsdefault longGet the default timeout for the operations in millisecondsdefault 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 booleanpublishConfigCas(String key, String group, String content, Object ticket) publish config mapped to this given key and given group with stat.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) Methods inherited from interface org.apache.dubbo.common.config.Configuration
containsKey, convert, getBoolean, getBoolean, getBoolean, getInt, getInt, getInteger, getInternalProperty, getProperty, getProperty, getString, getString
-
Field Details
-
DEFAULT_GROUP
- See Also:
-
-
Method Details
-
addListener
- Parameters:
key- the key to represent a configurationlistener- configuration listener
-
removeListener
- Parameters:
key- the key to represent a configurationlistener- configuration listener
-
addListener
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.- Parameters:
key- the key to represent a configurationgroup- the group where the key belongs tolistener- configuration listener
-
removeListener
Stops one listener from listening to value changes in the specified key.- Parameters:
key- the key to represent a configurationgroup- the group where the key belongs tolistener- configuration listener
-
getConfig
Get the configuration mapped to the given key and the given group withthe default timeout- Parameters:
key- the key to represent a configurationgroup- the group where the key belongs to- Returns:
- target configuration mapped to the given key and the given group
-
getConfigItem
get configItem which contains content and stat info.- Parameters:
key-group-- Returns:
-
getConfig
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.- Parameters:
key- the key to represent a configurationgroup- the group where the key belongs totimeout- timeout value for fetching the target config- Returns:
- target configuration mapped to the given key and the given group, IllegalStateException will be thrown if timeout exceeds.
- Throws:
IllegalStateException
-
getProperties
This method are mostly used to get a compound config file withthe default timeout, such as a complete dubbo.properties file.- Throws:
IllegalStateException
-
getProperties
This method are mostly used to get a compound config file, such as a complete dubbo.properties file.- Throws:
IllegalStateException
-
publishConfig
Publish Config mapped to the given key under thedefault group- Parameters:
key- the key to represent a configurationcontent- the content of configuration- Returns:
trueif success, orfalse- Throws:
UnsupportedOperationException- If the under layer does not support- Since:
- 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.- Parameters:
key- the key to represent a configurationgroup- the group where the key belongs tocontent- the content of configuration- Returns:
trueif success, orfalse- Throws:
UnsupportedOperationException- If the under layer does not support- Since:
- 2.7.5
-
publishConfigCas
default boolean publishConfigCas(String key, String group, String content, Object ticket) throws UnsupportedOperationException publish config mapped to this given key and given group with stat.- Parameters:
key-group-content-ticket-- Returns:
- Throws:
UnsupportedOperationException
-
getDefaultGroup
Get the default group for the operations- Returns:
- The default value is
"dubbo" - Since:
- 2.7.5
-
getDefaultTimeout
default long getDefaultTimeout()Get the default timeout for the operations in milliseconds- Returns:
- The default value is
-1L - Since:
- 2.7.5
-
close
Close the configuration- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- Since:
- 2.7.5
-
getRuleKey
The format is '{interfaceName}:[version]:[group]'- Returns:
-
removeConfig
- Parameters:
key- the key to represent a configurationgroup- the group where the key belongs to- Returns:
trueif success, orfalse- Since:
- 2.7.8
-