@ConfigurableContext public abstract class ConfigStore extends Context implements Closeable
Content stores require two methods to be implemented:
read(String) - Retrieve a config file.
write(String,String,String) - ConfigStore a config file.
| Modifier | Constructor and Description |
|---|---|
protected |
ConfigStore(PropertyStore ps)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
SessionArgs |
createDefaultSessionArgs()
Unused.
|
Session |
createSession(SessionArgs args)
Unused.
|
abstract boolean |
exists(String name)
Checks whether the configuration with the specified name exists in this store.
|
ConfigMap |
getMap(String name)
Returns a map file containing the parsed contents of a configuration.
|
abstract String |
read(String name)
Returns the contents of the configuration file.
|
ConfigStore |
register(String name,
ConfigStoreListener l)
Registers a new listener on this store.
|
protected String |
resolveName(String name)
Subclasses can override this method to convert config names to internal forms.
|
ObjectMap |
toMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
ConfigStore |
unregister(String name,
ConfigStoreListener l)
Unregisters a listener from this store.
|
ConfigStore |
update(String name,
String... contentLines)
Convenience method for updating the contents of a file with lines.
|
ConfigStore |
update(String name,
String contents)
Called when the physical contents of a config file have changed.
|
abstract String |
write(String name,
String expectedContents,
String newContents)
Saves the contents of the configuration file if the underlying storage hasn't been modified.
|
builder, createSession, equals, getArrayProperty, getArrayProperty, getBooleanProperty, getCdlProperty, getClassArrayProperty, getClassArrayProperty, getClassArrayProperty, getClassListProperty, getClassListProperty, getClassMapProperty, getClassMapProperty, getClassProperty, getClassSetProperty, getClassSetProperty, getInstanceArrayProperty, getInstanceArrayProperty, getInstanceArrayProperty, getInstanceProperty, getInstanceProperty, getInstanceProperty, getIntegerProperty, getListProperty, getListProperty, getLongProperty, getMapProperty, getProperty, getProperty, getPropertyKeys, getPropertyStore, getSetProperty, getSetProperty, getStringProperty, getStringPropertyWithNone, hashCode, identityCode, toStringprotected ConfigStore(PropertyStore ps)
ps - The settings for this content store.public abstract String read(String name) throws IOException
name - The config file name.IOException - Thrown by underlying stream.public abstract String write(String name, String expectedContents, String newContents) throws IOException
name - The config file name.expectedContents - The expected contents of the file.newContents - The new contents.IOException - Thrown by underlying stream.public abstract boolean exists(String name)
name - The config name.public ConfigStore register(String name, ConfigStoreListener l)
name - The configuration name to listen for.l - The new listener.public ConfigStore unregister(String name, ConfigStoreListener l)
name - The configuration name to listen for.l - The listener to unregister.public ConfigMap getMap(String name) throws IOException
name - The configuration name.IOException - Thrown by underlying stream.public ConfigStore update(String name, String contents)
Triggers calls to ConfigStoreListener.onChange(String) on all registered listeners.
name - The config name (e.g. the filename without the extension).contents - The new contents.public ConfigStore update(String name, String... contentLines)
name - The config name (e.g. the filename without the extension).contentLines - The new contents.protected String resolveName(String name)
For example, the ConfigFileStore class can take in both
name - The name to resolve.public final Session createSession(SessionArgs args)
createSession in class Contextargs - The session arguments.public final SessionArgs createDefaultSessionArgs()
createDefaultSessionArgs in class ContextCopyright © 2016–2019 The Apache Software Foundation. All rights reserved.