===============
What It Is
Quick Start
Postprocessing Features
Advanced Configuration
Usage example
Java Doc
The property loader is a java library for managing property configurations.
It supports several property loading strategies and features e.g.:
- Hierarchical/Ordered Property Loading (Master, User, System properties ....)
- Property templates
- Recursive Property Resolution
- Property encryption
- Build the lib:
$ maven install
- Include jar file to your application
- Add property files eg props.properties to your applications classpath
- Load properties:
PropertyLoader propertyLoader = new PropertyLoader().withDefaultConfig();
//loads: "props.properties", "props.$hostname.properties", "props.$user.properties"
Properties properties = propertyLoader.load("props")
####1. Variable Resolving
Variables in property values can be defined with
{$...}
Even nested variables are allowed, e.g.:
{$var{$innervar}e}
In the case above, the PropertyLoader will first resolve the inner variable, replace it, then resolve the outer variable.
####2. Includes
In order to include additional properties files from a properties files, add %include as a key with the file basenames separated by commas as its value, e.g.:
%include=file1,file2,file3
####3. Decryption
Encrypted property values that are prefixed with
DECRYPT:
will be decrypted after loading.
The PropertyLoader's default configuration includes default search paths, suffixes and applies all available postprocessing filters.
The default search paths are:
- the current directory
- the user's home directory
- the context classpath
The default suffixes are:
- local host names
- the user name
- 'override'
####1. Search Locations Tell the PropertyLoader to search for properties files at its default locations (/home/user, current directory and context classpath):
propertyLoader.atDefaultLocations()
#####1.1 Folders and URLs Tell the PropertyLoader to search for properties files at custom paths:
propertyLoader.atDirectory(String directory)
propertyLoader.atBaseURL(URL url)
propertyLoader.atCurrentDirectory()
propertyLoader.atHomeDirectory()
#####1.2 Classpath Tell the PropertyLoader to search for properties files in the current thread's classpath:
propertyLoader.atContextClassPath()
This will get the classloader from the current thread and use it to find properties files.
#####1.3 Classloader Tell the PropertyLoader to search for properties files using a custom ClassLoader:
propertyLoader.atClassLoader(ClassLoader classLoader)
#####1.4 Relative To A Class Tell the PropertyLoader to search for properties files relative to the location of a class:
propertyLoader.atRelativeToClass(Class<?> clazz)
####2. Suffixes Tell the PropertyLoader to use default suffixes (local host names, user name and "override"):
propertyLoader.addDefaultSuffixes()
Tell the PropertyLoader to use custom suffixes:
propertyLoader.addSuffix(String directory)
propertyLoader.addSuffixList(List<String> suffixes)
propertyLoader.addUserName()
propertyLoader.addLocalHostNames()
####3. Postprocessing
You can define which postprocessing filters are applied (includes are always processed if the key is present):
propertyLoader.withDefaultFilters()
propertyLoader.withVariableResolvingFilter()
propertyLoader.withEnvironmentResolvingFilter()
propertyLoader.withDecryptingFilter()
propertyLoader.withWarnIfPropertyHasToBeDefined()
propertyLoader.withWarnOnSurroundingWhitespace()
Full Java Doc of the code can be found here http://tng.github.io/property-loader/
Please have a look at CONTRIBUTING.md