setProperty operation on the
Properties interface sets a property to the specified value:
You can clear a property by setting it to the empty string.
For properties that control the Ice run time and its services (that is, properties that start with one of the reserved prefixes), this operation is useful only if you call it before you call
initialize. This is because property values are usually read by the Ice run time only once, when you call
initialize, so the Ice run time does not pay attention to a property value that is changed after you have initialized a communicator. Of course, this begs the question of how you can set a property value and have it also recognized by a communicator.
To permit you to set properties before initializing a communicator, the Ice run time provides an overloaded helper function or method called
createProperties that creates a property set.
createProperties is provided in all language mappings with overloads that accept the following parameters:
- no parameter at all
createPropertiescreates an empty property set, and does not check
ICE_CONFIGfor a configuration file to parse.
- the arguments given to the application plus a default property set
createPropertiesreturns a property set that contains all the property settings that are passed as the default, plus any property settings in the arguments. If the argument vector sets a property that is also set in the passed default property set, the setting in the argument vector overrides the default. It also looks for the
--Ice.Configoption; if the argument vector specifies a configuration file, the configuration file is parsed. The order of precedence of property settings, from lowest to highest, is:
- Property settings passed in the default parameter
- Property settings set in the configuration file
- Property settings in the argument vector (parsed as described in Command-Line Parsing and Initialization)
createPropertiesalso looks for the setting of the
ICE_CONFIGenvironment variable and, if that variable specifies a configuration file, parse that file. (However, an explicit
--Ice.Configoption in the argument vector or the
defaultsparameter overrides any setting of the
- the arguments given to the application
createPropertiesis like the
2.above, with an empty default property set.
createProperties strips Ice-related command-line options from the passed argument vector.
createProperties is useful if you want to ensure that a property is set to a particular value, regardless of any setting of that property in a configuration file or in the argument vector. Here is an example:
You can also set properties "in bulk" remotely through the Properties facet of Ice Admin.