public class ConfigurationDirectoryImpl extends ConfigurationAbstractImpl<Map<String,File>>
Configuration implementation used for directories. Instances of this class maintain a mapping of the relative
file path to the directory, like so:
EventBus eventBus = new EventBusSyncImpl();
Watch watch = Watch.config().withEventBus(eventBus);
// watches the directory specified in the master YAML under the 'clients' file entry
ConfigurationDirectoryImpl config = watch.directory("clients");
// grabs watchedDirectory/apple.properties
File appleFile = config.getValue().get("apple.properties");
// grabs watchedDirectory/google.properties
File googleFile = config.getValue().get("google.properties");
// grabs watchedDirectory/paypal/venmo.properties
File venmoFile = config.getValue().get("paypal/venmo.properties");
// grabs watchedDirectory/paypal/braintree.properties
File braintreeFile = config.getValue().get("paypal/braintree.properties");
| Constructor and Description |
|---|
ConfigurationDirectoryImpl(String sourceId,
File configFile,
EventBus eventBus) |
| Modifier and Type | Method and Description |
|---|---|
Map<String,File> |
load(File configFile)
Loads the configuration object from the configuration file.
|
void |
onFileEvent(FileEvent fileEvent)
Called when a file event published from the
ConfigurationAbstractImpl.eventBus is heard. |
protected void |
whenConfigFileDeleted(File configFile)
Called when the file associated with this object is
FileEventType.DELETED. |
getEventBus, getSourceId, getValue, init, onFileEventMatch, reload, whenConfigFileCreated, whenConfigFileUpdatedpublic ConfigurationDirectoryImpl(String sourceId, File configFile, EventBus eventBus) throws IOException
IOExceptionpublic void onFileEvent(FileEvent fileEvent) throws IOException
ConfigurationAbstractImplConfigurationAbstractImpl.eventBus is heard.onFileEvent in class ConfigurationAbstractImpl<Map<String,File>>fileEvent - Non-null file event which may or may not correspond to this configuration objectIOExceptionprotected void whenConfigFileDeleted(File configFile) throws IOException
ConfigurationAbstractImplFileEventType.DELETED. By default, this method does
nothing.whenConfigFileDeleted in class ConfigurationAbstractImpl<Map<String,File>>IOExceptionpublic Map<String,File> load(File configFile) throws IOException
ConfigurationconfigFile - Non-null configuration fileIOException - On any I/O error while reading the configuration fileCopyright © 2016–2017. All rights reserved.