In a system that contains many components, it is common that multiple components are initialized with the same property values. In order to maintain consistent property settings among these components, you can specify common property settings in one place, which the various components can all reference. Nucleus lets you link the property of one component to the property in another component through the ^=
operator, as follows:
property-name^=component-name.property-name
Note: No white space should precede or follow the ^=
operator.
For example, you might want to initialize the currentWeather
property in the Sunny
component from the currentWeather
property in the RainyWeather
component. To do this, set the Sunny
component’s properties file as follows:
$class=Weather
currentWeather^=RainyWeather.currentWeather
When Nucleus starts, the Sunny.
currentWeather
property obtains its value from RainyWeather.currentWeather
.
Note: Property linkage only occurs when the related components are initialized. After initialization, the linked properties are completely independent. So, given the previous example, changes to RainyWeather.currentWeather
have no effect on Sunny.currentWeather
.
Typically, frequently modified configuration values are placed into properties of a single component, which only serves to hold the property values referenced by other component. All components in the application that need those values link their properties to this component.