Package net.obvj.confectory.source
Class DynamicSource<T>
- java.lang.Object
-
- net.obvj.confectory.source.AbstractSource<T>
-
- net.obvj.confectory.source.DynamicSource<T>
-
- All Implemented Interfaces:
Source<T>
public class DynamicSource<T> extends AbstractSource<T> implements Source<T>
A dynamic
Sourceimplementation which applies a different loading strategy contingent on the path contents.- A path starting with
"file://"or"http://"will be loaded by theURLSource - A path starting with
"classpath://"will be loaded by theClasspathFileSource
For example:
- The following instruction creates a dynamic
Sourcethat loads files from the file system:new DynamicSource("file:///path/my-file.properties") - The following instruction creates a dynamic
Sourcethat loads a file resource from the Java classpath:new DynamicSource("classpath://my-file.properties")
If unable to determine the source by prefix, the system will do best efforts to load the object by applying different
Sourceimplementations.- Since:
- 0.1.0
- Author:
- oswaldo.bapvic.jr (Oswaldo Junior)
- See Also:
FileSource,ClasspathFileSource
-
-
Constructor Summary
Constructors Constructor Description DynamicSource(String path)Builds a new dynamic configuration source from a specific path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tload(Mapper<T> mapper)Applies a specific configuration loading strategy and returns a mapped bean containing the retrieved data, throwing an exception if the operation fails.-
Methods inherited from class net.obvj.confectory.source.AbstractSource
equals, hashCode, load, toString
-
-
-
-
Constructor Detail
-
DynamicSource
public DynamicSource(String path)
Builds a new dynamic configuration source from a specific path.- Parameters:
path- the path for this configuration source
-
-