Within an application, you can set properties of several components to the same value by using global properties files. A global properties file (with the name, GLOBAL.properties) can be placed into a configuration directory. Property values found there will be applied to all components defined in that directory, or any of its subdirectories.

For example, if the following line is in localconfig/services/GLOBAL.properties:

currentWeather=miserably hot

then any component contained by /services will have its currentWeather property set to miserably hot. This includes not only immediate children of /services such as sunnyWeather and rainyWeather, but any descendants of /services, such as /services/regional/newEngland/massachusetts.properties

Global properties only apply to components that have the specified property. If a component does not have a currentWeather property, for example, then that global property will have no effect on the component.

Global properties can be overridden by declaring the property values in those components. For example, if sunnyWeather declares a currentWeather property, then that value will be used instead of the wildcard property value. But if rainyWeather does not declare a value for its currentWeather property, then the global property value is used.

A component might be affected by multiple global properties files. For example, the sunnyWeather component might be affected by localconfig/services/sunnyWeather.properties, localconfig/services/GLOBAL.properties, and localconfig/GLOBAL.properties. Nucleus examines the properties files from top to bottom, so values in localconfig/services/sunnyWeather.properties will override values in localconfig/services/GLOBAL.properties, and values in localconfig/services/GLOBAL.properties, will override values in localconfig/GLOBAL.properties.

The technique of appending property values can also be used with global properties. For example, a global properties file might declare the following property:

affectedCities=\
        Detroit,\
        Boston,\
        Los Angeles

and a contained component might declare:

affectedCities+=Chicago

The contained component will have its affectedCities property set to Detroit,Boston,Los Angeles,Chicago.

 
loading table of contents...