public class ConfigFileStore extends ConfigStore
Points to a file system directory containing configuration files.
Modifier and Type | Field and Description |
---|---|
static ConfigFileStore |
DEFAULT
Default file store, all default values.
|
static String |
FILESTORE_charset
Configuration property: Charset.
|
static String |
FILESTORE_directory
Configuration property: Local file system directory.
|
static String |
FILESTORE_updateOnWrite
Configuration property: Update-on-write.
|
static String |
FILESTORE_useWatcher
Configuration property: Use watcher.
|
static String |
FILESTORE_watcherSensitivity
Configuration property: Watcher sensitivity.
|
Modifier | Constructor and Description |
---|---|
protected |
ConfigFileStore(PropertyStore ps)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ConfigFileStoreBuilder |
builder()
Creates a builder from this context object.
|
void |
close() |
static ConfigFileStoreBuilder |
create()
Create a new builder for this object.
|
protected void |
onFileEvent(WatchEvent<Path> e)
Gets called when the watcher service on this store is triggered with a file system change.
|
String |
read(String name)
Returns the contents of the configuration file.
|
ConfigFileStore |
update(String name,
String newContents)
Called when the physical contents of a config file have changed.
|
String |
write(String name,
String expectedContents,
String newContents)
Saves the contents of the configuration file if the underlying storage hasn't been modified.
|
createDefaultSessionArgs, createSession, getMap, register, unregister, update
asMap, createSession, equals, getArrayProperty, getArrayProperty, getBooleanProperty, 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, hashCode, toString
public static final String FILESTORE_directory
String
Identifies the path of the directory containing the configuration files.
public static final String FILESTORE_charset
Charset
Charset.defaultCharset()
Identifies the charset of external files.
public static final String FILESTORE_useWatcher
Boolean
Use a file system watcher for file system changes.
close()
on this object closes the watcher.
public static final String FILESTORE_watcherSensitivity
WatcherSensitivity
WatcherSensitivity.MEDIUM
Determines how frequently the file system is polled for updates.
public static final String FILESTORE_updateOnWrite
Boolean
When enabled, the update(String, String)
method will be called immediately following
calls to write(String, String, String)
when the contents are changing.
This allows for more immediate responses to configuration changes on file systems that use
polling watchers.
This may cause double-triggering of ConfigStoreListeners
.
public static final ConfigFileStore DEFAULT
protected ConfigFileStore(PropertyStore ps)
ps
- The settings for this content store.public static ConfigFileStoreBuilder create()
public ConfigFileStoreBuilder builder()
Context
Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
public String read(String name) throws IOException
ConfigStore
read
in class ConfigStore
name
- The config file name.IOException
public String write(String name, String expectedContents, String newContents) throws IOException
ConfigStore
write
in class ConfigStore
name
- The config file name.expectedContents
- The expected contents of the file.newContents
- The new contents.IOException
public ConfigFileStore update(String name, String newContents)
ConfigStore
Triggers calls to ConfigStoreListener.onChange(String)
on all registered listeners.
update
in class ConfigStore
name
- The config name (e.g. the filename without the extension).newContents
- The new contents.public void close()
protected void onFileEvent(WatchEvent<Path> e) throws IOException
e
- The file system event.IOException
Copyright © 2018 Apache. All rights reserved.