public final class FileDataSourceBuilder extends java.lang.Object implements DataSourceFactory
FileData.dataSource(),
call the builder method filePaths(String...) to specify file path(s),
then pass the resulting object to LDConfig.Builder.dataSource(DataSourceFactory).
For more details, see FileData.
| Constructor and Description |
|---|
FileDataSourceBuilder() |
| Modifier and Type | Method and Description |
|---|---|
FileDataSourceBuilder |
autoUpdate(boolean autoUpdate)
Specifies whether the data source should watch for changes to the source file(s) and reload flags
whenever there is a change.
|
DataSource |
createDataSource(ClientContext context,
DataSourceUpdates dataSourceUpdates)
Used internally by the LaunchDarkly client.
|
FileDataSourceBuilder |
filePaths(java.nio.file.Path... filePaths)
Adds any number of source files for loading flag data, specifying each file path as a Path.
|
FileDataSourceBuilder |
filePaths(java.lang.String... filePaths)
Adds any number of source files for loading flag data, specifying each file path as a string.
|
public FileDataSourceBuilder filePaths(java.lang.String... filePaths) throws java.nio.file.InvalidPathException
Files will be parsed as JSON if their first non-whitespace character is '{'. Otherwise, they will be parsed as YAML.
filePaths - path(s) to the source file(s); may be absolute or relative to the current working directoryjava.nio.file.InvalidPathException - if one of the parameters is not a valid file pathpublic FileDataSourceBuilder filePaths(java.nio.file.Path... filePaths)
Files will be parsed as JSON if their first non-whitespace character is '{'. Otherwise, they will be parsed as YAML.
filePaths - path(s) to the source file(s); may be absolute or relative to the current working directorypublic FileDataSourceBuilder autoUpdate(boolean autoUpdate)
Note that auto-updating will only work if all of the files you specified have valid directory paths at startup time; if a directory does not exist, creating it later will not result in files being loaded from it.
autoUpdate - true if flags should be reloaded whenever a source file changespublic DataSource createDataSource(ClientContext context, DataSourceUpdates dataSourceUpdates)
createDataSource in interface DataSourceFactorycontext - allows access to the client configurationdataSourceUpdates - the component pushes data into the SDK via this interfaceDataSource