LibraryLink ToToggle FramesPrintFeedback

Customizing Fixed Value Attribute Mapping

By default, the code generators map attributes defined as having a fixed value to normal properties. When using schema validation, Apache CXF can enforce the schema definition. However, using schema validation increases message processing time.

Another way to map attributes that have fixed values to Java is to map them to Java constants. You can instruct the code generator to map fixed value attributes to Java constants using the globalBindings customization element. You can also customize the mapping of fixed value attributes to Java constants at a more localized level using the property element.

You can alter this behavior by adding the globalBinding element's fixedAttributeAsConstantProperty attribute. Setting this attribute to true instructs the code generator to map any attribute defined using fixed attribute to a Java constant.

Example 16.21 shows an in-line customization that forces the code generator to generate constants for attributes with fixed values.


Example 16.22 shows an external binding file that customizes the generation of fixed attributes.


You can customize attribute mapping on a per-attribute basis using the property element's fixedAttributeAsConstantProperty attribute. Setting this attribute to true instructs the code generator to map any attribute defined using fixed attribute to a Java constant.

Example 16.23 shows an in-line customization that forces the code generator to generate constants for a single attribute with a fixed value.


Example 16.24 shows an external binding file that customizes the generation of a fixed attribute.


In the default mapping, all attributes are mapped to standard Java properties with getter and setter methods. When this customization is applied to an attribute defined using the fixed attribute, the attribute is mapped to a Java constant, as shown in Example 16.25.


type is determined by mapping the base type of the attribute to a Java type using the mappings described in Primitive Types.

NAME is determined by converting the value of the attribute element's name attribute to all capital letters.

value is determined by the value of the attribute element's fixed attribute.

For example, the attribute defined in Example 16.23 is mapped as shown in Example 16.26.