public interface DynamicConfiguration extends Configuration, AutoCloseable
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 configAbstractDynamicConfiguration| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_GROUP |
| Modifier and Type | Method and Description |
|---|---|
default void |
addListener(String key,
ConfigurationListener listener)
|
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.
|
default void |
close()
Close the configuration
|
default String |
getConfig(String key,
String group)
Get the configuration mapped to the given key and the given group with
the default
timeout |
String |
getConfig(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 group
|
default String |
getDefaultGroup()
Get the default group for the operations
|
default long |
getDefaultTimeout()
Get the default timeout for the operations in milliseconds
|
static DynamicConfiguration |
getDynamicConfiguration()
Find DynamicConfiguration instance
|
static DynamicConfiguration |
getDynamicConfiguration(URL connectionURL)
Get the instance of
DynamicConfiguration by the specified connection URL |
default String |
getProperties(String key,
String group)
This method are mostly used to get a compound config file with
the default timeout,
such as a complete dubbo.properties file. |
default String |
getProperties(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 String |
getRuleKey(URL url)
The format is '{interfaceName}:[version]:[group]'
|
default boolean |
publishConfig(String key,
String content)
Publish Config mapped to the given key under the
default group |
default boolean |
publishConfig(String key,
String group,
String content)
Publish Config mapped to the given key and the given group.
|
default void |
removeListener(String key,
ConfigurationListener listener)
|
void |
removeListener(String key,
String group,
ConfigurationListener listener)
Stops one listener from listening to value changes in the specified key.
|
containsKey, convert, getBoolean, getBoolean, getBoolean, getInt, getInt, getInteger, getInternalProperty, getProperty, getProperty, getString, getString, toBooleanObjectstatic final String DEFAULT_GROUP
default void addListener(String key, ConfigurationListener listener)
key - the key to represent a configurationlistener - configuration listenerdefault void removeListener(String key, ConfigurationListener listener)
key - the key to represent a configurationlistener - configuration listenervoid addListener(String key, String group, ConfigurationListener listener)
key - the key to represent a configurationgroup - the group where the key belongs tolistener - configuration listenervoid removeListener(String key, String group, ConfigurationListener listener)
key - the key to represent a configurationgroup - the group where the key belongs tolistener - configuration listenerdefault String getConfig(String key, String group)
the default
timeoutkey - the key to represent a configurationgroup - the group where the key belongs toString getConfig(String key, String group, long timeout) throws IllegalStateException
key - the key to represent a configurationgroup - the group where the key belongs totimeout - timeout value for fetching the target configIllegalStateExceptiondefault String getProperties(String key, String group) throws IllegalStateException
the default timeout,
such as a complete dubbo.properties file.IllegalStateExceptiondefault String getProperties(String key, String group, long timeout) throws IllegalStateException
IllegalStateExceptiondefault boolean publishConfig(String key, String content) throws UnsupportedOperationException
default groupkey - the key to represent a configurationcontent - the content of configurationtrue if success, or falseUnsupportedOperationException - If the under layer does not supportdefault boolean publishConfig(String key, String group, String content) throws UnsupportedOperationException
key - the key to represent a configurationgroup - the group where the key belongs tocontent - the content of configurationtrue if success, or falseUnsupportedOperationException - If the under layer does not supportdefault SortedSet<String> getConfigKeys(String group) throws UnsupportedOperationException
group - the specified groupset of config keysUnsupportedOperationException - If the under layer does not supportdefault String getDefaultGroup()
"dubbo"default long getDefaultTimeout()
-1Ldefault void close()
throws Exception
close in interface AutoCloseableExceptionstatic DynamicConfiguration getDynamicConfiguration()
static DynamicConfiguration getDynamicConfiguration(URL connectionURL)
DynamicConfiguration by the specified connection URLconnectionURL - Copyright © 2011–2020 The Apache Software Foundation. All rights reserved.