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
FilePropertiesLoaderloads '.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
PropertiesResources to load can be configured using the according constructor.An instance of this
FilePropertiesLoadercan be used in several threads concurrently.- Author:
- sts
-
-
Constructor Summary
Constructors Constructor Description FilePropertiesLoader(java.lang.String filePath)Constructs aFilePropertiesLoaderusing the given file-path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetFileName(PropertiesResource propertiesResource)Returns the filename used by thisPropertiesLoaderwhen it tries to load the givenPropertiesResource.java.lang.StringgetFilePath(PropertiesResource propertiesResource)Returns the file path build by thisPropertiesLoaderwhen it tries to load the givenPropertiesResource.java.util.Propertiesload(PropertiesResource propertiesResource)Loads the givenPropertiesResourceif present.java.lang.StringtoString()-
Methods inherited from class com.saperion.common.config.loader.AbstractPropertiesLoader
loadAsMap
-
-
-
-
Constructor Detail
-
FilePropertiesLoader
public FilePropertiesLoader(java.lang.String filePath)
Constructs aFilePropertiesLoaderusing the given file-path. The file-path is appended as prefix to the file name when thisPropertiesLoaderloads aPropertiesResource.- Parameters:
filePath- the file-path to use for loading thePropertiesResources. May not benullor empty.
-
-
Method Detail
-
load
public java.util.Properties load(PropertiesResource propertiesResource) throws ConfigurationException
Description copied from interface:PropertiesLoaderLoads the givenPropertiesResourceif present. Returns the properties as aPropertiesobject.- Parameters:
propertiesResource- thePropertiesResourceto load.- Returns:
- the loaded
Properties - Throws:
ConfigurationException- if thePropertiesResourcecould not be loaded.- See Also:
PropertiesResource,Properties
-
getFileName
public static java.lang.String getFileName(PropertiesResource propertiesResource)
Returns the filename used by thisPropertiesLoaderwhen it tries to load the givenPropertiesResource.- Parameters:
propertiesResource- thePropertiesResourceto get the filename for.- Returns:
- filename used by this
PropertiesLoaderwhen it loads the givenPropertiesResource
-
getFilePath
public java.lang.String getFilePath(PropertiesResource propertiesResource)
Returns the file path build by thisPropertiesLoaderwhen it tries to load the givenPropertiesResource.- Parameters:
propertiesResource- thePropertiesResourceto get the search path for.- Returns:
- the file path build by this
PropertiesLoaderwhen it tries to load the givenPropertiesResource.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-