In a system containing many components, it is not unusual for several components to be initialized with the same property values. This can lead to confusion for the administrator if the value is changed in one component, but not changed in the other components.

Ideally, the value would be specified in one place, and all the components would read that value for their individual properties. Nucleus allows you to do this by linking one property value to the value of another property in another service.

To do this, append a “^” to the name of the property you want to set. For the value, enter the component name and property name whose value is to be copied into this property.

For example, say that we want the SunnyWeather component to be initialized with the same currentWeather property as the RainyWeather component. To do this, modify the SunnyWeather properties file to look like this:

$class=Weather
currentWeather^=RainyWeather.currentWeather

Now, when Nucleus is started, both SunnyWeather and RainyWeather will be initialized with the same currentWeather property value.

The ^ character must come right after the currentWeather name without any intervening white space, so this will not work:

currentWeather ^= RainyWeather.currentWeather

Note that this linkage only occurs at the time the component is initialized. After initialization, both property values are completely independent — if one component changes its currentWeather property, the other component’s currentWeather property will remain unaffected.

You can link properties using the Component Editor by selecting the value of a property in the Properties tab and clicking the @ button. The Component Editor presents a dialog that displays all the available components in your application. You can then select the component, or property of a component, to which you want to link. The Component Editor automatically edits the related properties file to set the new value with the ^ character.

A typical use of this feature is to place the most frequently modified configuration values into properties of a single component, perhaps called Configuration. Then all of the components in the application that need those values would link their values from the properties of the Configuration component. The Configuration component itself would do nothing but hold property values.

 
loading table of contents...