com.netflix.eventbus.spi
Interface SubscriberConfigProvider
public interface SubscriberConfigProvider
A contract to handle dynamic subscriber configuration. Since, any configuration provided by Subscribe
annotation is inherently compile-time & constant, in cases where the configurations are to be taken from a property
file for instance, a subscriber must implement this interface and provide dynamic configurations.
These configurations will be used once & only once by eventbus at the time the subscriber is registered.
All the subscriber methods in a class can be configured using this provider, by pinning a configuration to a key
which is attached to a subscriber method by the property Subscribe.name().
For a subscriber that implements interface, for any subscriber method, eventbus follows the following order to get
the configuration for that subscriber method:
- Calls
getConfigForName(String) with the name as specified by
Subscribe.name()
- If the configuration returned above is not
null then uses this configuration for any field.
- If the configuration returned above is
null then uses any configuration provided by the annotation
as is.
getConfigForName
@Nullable
SubscriberConfigProvider.SubscriberConfig getConfigForName(java.lang.String subscriberName)
- Returns the configuration for the passed subscriber name.
- Parameters:
subscriberName - Name of the subscriber.
- Returns:
- The configuration or
null if the configuration for that subscriber is not supplied by this
provider.