Property-Default
Description
Sets a property to the value of a specified property or specified default value if the other does not exist.
Parameters
| Attribute | Description | Required |
|---|---|---|
| property | The name of the property to set | Yes |
| from | The name of the property you wish to set the value from. Embedded property references will be expanded. | Yes (unless propertylist element is set) |
| default | The default value to set property if no value can be used given "from" property or propertylist. Embedded property references will be expanded. | No |
| ignoremalformed | Boolean setting specifying if malformed values should be ignored. Malformed values are those that contain the pattern ${.*} after property names have been expanded. If set true, then property will not be set. If false, then property will be set to the value containing the malformed value. | No (default "false") |
| override | If the property is already set, should we change it's value. Can be true or false | No (defaults to "false") |
Parameters specified as nested elements
propertylist
Contains a list of property names to set the default. Mutually, exclusive with the from attribute. The property will be defaulted to the first valid (i.e., not malformed) property in the list. If no valid property is in the list, then the value will be set to the default attribute if one exists otherwise no default is defined and property remains unset.
| Attribute | Description | Required |
|---|---|---|
| names | Delimited list of property names | Yes |
| delimiter | List delimiter | No. (defaults to ",") |
<propertylist names="name1,name2,...,nameN" delimiter=","/>
Examples
Set opts.port from the property, an_httpPort, if that property exists otherwsie set it to 80.
<property name="alt_httpPort" value="8080"/>
<property-default
property="opts.port"
from="alt_httpPort"
default="80"/>
Set the property cmd.foo from the first existing property in the propertylist.
<property-default property="cmd.foo">
<propertylist
names="opts.foo,entity.attribute.foo"/>
</property-default>
The next example attempts to set property cmd.X from a property that has a non-existent value. Since no default attribute was set, cmd.X should remain unset.
<property name="x" value="${nonExistent}"/>
<property-default
property="cmd.X"
from="x"
ignoremalformed="true"/>
<fail if="cmd.X">this should not fail</fail>



