ControlTier Inc. > CTL
 
Font size:      

Property-Default

Description

Sets a property to the value of a specified property or specified default value if the other does not exist.

Parameters

AttributeDescriptionRequired
propertyThe name of the property to setYes
fromThe name of the property you wish to set the value from. Embedded property references will be expanded.Yes (unless propertylist element is set)
defaultThe default value to set property if no value can be used given "from" property or propertylist. Embedded property references will be expanded. No
ignoremalformedBoolean 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")
overrideIf the property is already set, should we change it's value. Can be true or falseNo (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.

AttributeDescriptionRequired
namesDelimited list of property namesYes
delimiterList delimiterNo. (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>