Package org.jgrapes.util
Class NightConfigStore
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.util.ConfigurationStore
org.jgrapes.util.NightConfigStore
- All Implemented Interfaces:
Iterable<ComponentType>,Channel,ComponentType,Eligible,Manager
- Direct Known Subclasses:
JsonConfigurationStore,TomlConfigurationStore,YamlConfigurationStore
A base class for configuration stored based on the
night config library.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.electronwill.nightconfig.core.file.FileConfigprotected Channel[]protected static final LoggerFields inherited from class org.jgrapes.util.ConfigurationStore
NUMBER -
Constructor Summary
ConstructorsConstructorDescriptionNightConfigStore(Channel componentChannel, File file) Deprecated.NightConfigStore(Channel componentChannel, File file, boolean update) Deprecated.NightConfigStore(Channel componentChannel, File file, boolean update, boolean watch) Creates a new component with its channel set to the given channel and the given file. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanChecks if the name is an entry for a node.voidMerges and saves configuration updates.voidonFileChanged(FileChanged event) If watching the configuration file is enabled, fire aConfigurationUpdateevent with the complete configuration when the file changes.voidIntercepts theStartevent and fires aConfigurationUpdateevent.structured(String path) Return the properties for a given path if they exists as structured data, seeConfigurationStore.structure(Map).Methods inherited from class org.jgrapes.util.ConfigurationStore
as, asBoolean, asInstant, asNumber, asString, flatten, mergeValue, structure, structure, valuesMethods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setNameMethods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGeneratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
logger
-
config
-
initialChannels
-
-
Constructor Details
-
NightConfigStore
Deprecated.Creates a new component with its channel set to the given channel and the given file.The component handles
ConfigurationUpdateevents andFileChangedevents for the configuration file (see- Throws:
IOException
-
NightConfigStore
@Deprecated public NightConfigStore(Channel componentChannel, File file, boolean update) throws IOException Deprecated.Creates a new component with its channel set to the given channel and the given file.The component handles
FileChangedevents for the configuration file (see- Throws:
IOException
-
NightConfigStore
public NightConfigStore(Channel componentChannel, File file, boolean update, boolean watch) throws IOException Creates a new component with its channel set to the given channel and the given file.If
updateistrue, the configuration file is updated whenConfigurationUpdateevents are received.If
watchistrue,FileChangedevents are processed and the configuration file is reloaded when it changes. Note that the generation of theFileChangedevents must be configured independently (seeFileSystemWatcher).- Parameters:
componentChannel- the channelfile- the file used to store the configurationupdate- if the configuration file is to be updatedwatch- ifFileChangedevents are to be processed- Throws:
IOException- Signals that an I/O exception has occurred.
-
-
Method Details
-
onFileChanged
If watching the configuration file is enabled, fire aConfigurationUpdateevent with the complete configuration when the file changes.The event is fired on the same channel(s) as the
InitialConfigurationevent.- Parameters:
event- the event
-
structured
Description copied from class:ConfigurationStoreReturn the properties for a given path if they exists as structured data, seeConfigurationStore.structure(Map).- Overrides:
structuredin classConfigurationStore- Parameters:
path- the path- Returns:
- the values, if defined for the given path
-
isNode
Checks if the name is an entry for a node.- Parameters:
name- the name- Returns:
- true, if is node
-
onStart
@Handler(priority=999999, channels=Channel.class) public void onStart(Start event) throws BackingStoreException, InterruptedException Intercepts theStartevent and fires aConfigurationUpdateevent.- Parameters:
event- the event- Throws:
BackingStoreException- the backing store exceptionInterruptedException- the interrupted exception
-
onConfigurationUpdate
@Handler(dynamic=true) public void onConfigurationUpdate(ConfigurationUpdate event) throws IOException Merges and saves configuration updates.- Parameters:
event- the event- Throws:
IOException- Signals that an I/O exception has occurred.
-