Reading system properties

EasyConf integrates the system properties to unify the sources of configuration. This feature can be used to override the value of a property existent in a properties file or to define a new property.

When used to overwrite a value of an existent property, the property name must be prefixed by the name of the component. For example, if you have in my-component.properties:

db.type=default
         

You can overwrite this value executing the application with the following command line arguments:

java -Dmy-component:db.type=oracle MyApp
			

System properties are also available to be used as variables in the properties files. For example:

users.database.type=${db.type}
         

Specifying system properties that will act as new properties is useful, for example, when including files. Using this feature you can allow the user to choose the name of the file that will contain properties with overridden values (Rememenber that if the file does not exist it will be silently ignored). For example, if you execute the application with:

java -Dexternal-file=my-external-file.properties
			

You can include an external file in my-component.properties with:

include-and-override=${external-file}
         

This feature is used to support multiple environemnts