Class FilePropertiesLoader
- java.lang.Object
-
- com.saperion.common.config.loader.AbstractPropertiesLoader
-
- com.saperion.common.config.loader.FilePropertiesLoader
-
- All Implemented Interfaces:
PropertiesLoader
public final class FilePropertiesLoader extends AbstractPropertiesLoader
This
FilePropertiesLoader
loads '.properties'-files. When loading a file it first attempts to find the file in the class-path. If not found, it tries to find the file in the file-system.The path to look for the
PropertiesResource
s to load can be configured using the according constructor.An instance of this
FilePropertiesLoader
can be used in several threads concurrently.- Author:
- sts
-
-
Constructor Summary
Constructors Constructor Description FilePropertiesLoader(java.lang.String filePath)
Constructs aFilePropertiesLoader
using the given file-path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getFileName(PropertiesResource propertiesResource)
Returns the filename used by thisPropertiesLoader
when it tries to load the givenPropertiesResource
.java.lang.String
getFilePath(PropertiesResource propertiesResource)
Returns the file path build by thisPropertiesLoader
when it tries to load the givenPropertiesResource
.java.util.Properties
load(PropertiesResource propertiesResource)
Loads the givenPropertiesResource
if present.java.lang.String
toString()
-
Methods inherited from class com.saperion.common.config.loader.AbstractPropertiesLoader
loadAsMap
-
-
-
-
Constructor Detail
-
FilePropertiesLoader
public FilePropertiesLoader(java.lang.String filePath)
Constructs aFilePropertiesLoader
using the given file-path. The file-path is appended as prefix to the file name when thisPropertiesLoader
loads aPropertiesResource
.- Parameters:
filePath
- the file-path to use for loading thePropertiesResource
s. May not benull
or empty.
-
-
Method Detail
-
load
public java.util.Properties load(PropertiesResource propertiesResource) throws ConfigurationException
Description copied from interface:PropertiesLoader
Loads the givenPropertiesResource
if present. Returns the properties as aProperties
object.- Parameters:
propertiesResource
- thePropertiesResource
to load.- Returns:
- the loaded
Properties
- Throws:
ConfigurationException
- if thePropertiesResource
could not be loaded.- See Also:
PropertiesResource
,Properties
-
getFileName
public static java.lang.String getFileName(PropertiesResource propertiesResource)
Returns the filename used by thisPropertiesLoader
when it tries to load the givenPropertiesResource
.- Parameters:
propertiesResource
- thePropertiesResource
to get the filename for.- Returns:
- filename used by this
PropertiesLoader
when it loads the givenPropertiesResource
-
getFilePath
public java.lang.String getFilePath(PropertiesResource propertiesResource)
Returns the file path build by thisPropertiesLoader
when it tries to load the givenPropertiesResource
.- Parameters:
propertiesResource
- thePropertiesResource
to get the search path for.- Returns:
- the file path build by this
PropertiesLoader
when it tries to load the givenPropertiesResource
.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-