- java.lang.Object
-
- org.github.gestalt.config.reload.ConfigReloadStrategy
-
- Direct Known Subclasses:
FileChangeReloadStrategy,ManualConfigReloadStrategy,TimedConfigReloadStrategy
public abstract class ConfigReloadStrategy extends java.lang.ObjectBaseclass for all reload strategies. Holds all the config reload listeners and the source we want to watch for. On reload it will call the listeners with the sources.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<ConfigReloadListener>listenersThe listeners for the Config Reload.protected ConfigSourcesourceThe source we are listening for a reload.
-
Constructor Summary
Constructors Modifier Constructor Description protectedConfigReloadStrategy()Protected constructor for the ConfigReloadStrategy.protectedConfigReloadStrategy(ConfigSource source)Protected constructor for the ConfigReloadStrategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigSourcegetSource()Get the source this reload strategy should apply to.voidregisterListener(ConfigReloadListener listener)Add a config reload listener.protected voidreload()call all listeners with the reload event.voidremoveListener(ConfigReloadListener listener)Remove a config reload listener.voidsetSource(ConfigSource source)set the source this reload strategy should apply to.
-
-
-
Field Detail
-
listeners
protected final java.util.List<ConfigReloadListener> listeners
The listeners for the Config Reload.
-
source
protected ConfigSource source
The source we are listening for a reload.
-
-
Constructor Detail
-
ConfigReloadStrategy
protected ConfigReloadStrategy()
Protected constructor for the ConfigReloadStrategy. So end users cant create this class, only inherit it.
-
ConfigReloadStrategy
protected ConfigReloadStrategy(ConfigSource source)
Protected constructor for the ConfigReloadStrategy. So end users cant create this class, only inherit it.- Parameters:
source- source we are listening for a reload
-
-
Method Detail
-
getSource
public ConfigSource getSource()
Get the source this reload strategy should apply to.- Returns:
- the source this reload strategy should apply to.
-
setSource
public void setSource(ConfigSource source) throws GestaltConfigurationException
set the source this reload strategy should apply to.- Parameters:
source- the source this reload strategy should apply to.- Throws:
GestaltConfigurationException- if there is an exception setting the source
-
registerListener
public void registerListener(ConfigReloadListener listener)
Add a config reload listener.- Parameters:
listener- a config reload listener.
-
removeListener
public void removeListener(ConfigReloadListener listener)
Remove a config reload listener.- Parameters:
listener- a config reload listener.
-
reload
protected void reload() throws GestaltExceptioncall all listeners with the reload event.- Throws:
GestaltException- any exceptions
-
-