Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.このコンテンツは選択した言語では利用できません。
38.5. Customizing Fixed Value Attribute Mapping
Overview リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
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.
Global customization リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
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 38.21, “in-Line Customization to Force Generation of Constants” shows an in-line customization that forces the code generator to generate constants for attributes with fixed values.
Example 38.21. in-Line Customization to Force Generation of Constants
Example 38.22, “Binding File to Force Generation of Constants” shows an external binding file that customizes the generation of fixed attributes.
Example 38.22. Binding File to Force Generation of Constants
Local mapping リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
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 38.23, “In-Line Customization to Force Generation of Constants” shows an in-line customization that forces the code generator to generate constants for a single attribute with a fixed value.
Example 38.23. In-Line Customization to Force Generation of Constants
Example 38.24, “Binding File to Force Generation of Constants” shows an external binding file that customizes the generation of a fixed attribute.
Example 38.24. Binding File to Force Generation of Constants
Java mapping リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
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 38.25, “Mapping of a Fixed Value Attribute to a Java Constant”.
Example 38.25. Mapping of a Fixed Value Attribute to a Java Constant
@XmlAttribute public final static type NAME = value;
@XmlAttribute
public final static type NAME = value;
type is determined by mapping the base type of the attribute to a Java type using the mappings described in Section 34.1, “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 38.23, “In-Line Customization to Force Generation of Constants” is mapped as shown in Example 38.26, “Fixed Value Attribute Mapped to a Java Constant”.
Example 38.26. Fixed Value Attribute Mapped to a Java Constant