@Retention(value=RUNTIME) @Target(value=METHOD) @Documented public @interface ApolloConfigChangeListener
Usage example:
//Listener on namespaces of "someNamespace" and "anotherNamespace", will be notified when any key is changed
@ApolloConfigChangeListener({"someNamespace","anotherNamespace"})
private void onChange(ConfigChangeEvent changeEvent) {
//handle change event
}
//Listener on namespaces of "someNamespace" and "anotherNamespace", will only be notified when "someKey" or "anotherKey" is changed
@ApolloConfigChangeListener(value = {"someNamespace","anotherNamespace"}, interestedKeys = {"someKey", "anotherKey"})
private void onChange(ConfigChangeEvent changeEvent) {
//handle change event
}
| 限定符和类型 | 可选元素和说明 |
|---|---|
String[] |
interestedKeyPrefixes
The key prefixes that the listener is interested in, will be notified if and only if the changed keys start with anyone of the prefixes.
|
String[] |
interestedKeys
The keys interested by the listener, will only be notified if any of the interested keys is changed.
|
String[] |
value
Apollo namespace for the config, if not specified then default to application
|
public abstract String[] value
public abstract String[] interestedKeys
interestedKeys and interestedKeyPrefixes is specified then the listener will be notified when any key is changed.public abstract String[] interestedKeyPrefixes
listener should be notified or not using changedKey.startsWith(prefix).
e.g. "spring." means that listener is interested in keys that starts with "spring.", such as "spring.banner", "spring.jpa", etc.
and "application" means that listener is interested in keys that starts with "application", such as "applicationName", "application.port", etc.
interestedKeys and interestedKeyPrefixes is specified then the listener will be notified when whatever key is changed.Copyright © 2019 Ctrip, Inc.. All rights reserved.