Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example 6: Using xjc extensions

Standard JAXB command-line customizations can be added via <extraarg> elements, either one per line or comma separated. CXF also offers some JAXB extensions for the code generation. They have to be added as depdendencies dependencies and then activated by using an extraarg with content -xjc-X<extension id>

artifact id

description

extension id

cxf-xjc-boolean

Adds getters for booleans

boolean

cxf-xjc-bug671

Workaroung for JAXB bug 671

bug671

cxf-xjc-dv

Default value support

dv

cxf-xjc-ts

Adds toString to objects

ts

cxf-xjc-wsdlextension

WsdlExtension support

wsdlextension

jaxb-fluent-api

Fluent API for setters

fluent-api

An example showing attachment of a JAXB binding file and the CXF toString() extension is below:

Code Block
xml
xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
  <execution>
    <id>generate-sources</id>
    <phase>generate-sources</phase>
    <configuration>
      <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
      <wsdlOptions>
        <wsdlOption>
          <wsdl>${basedir}/src/main/wsdl/myService.wsdl</wsdl>
          <extraargs>
            <extraarg>-xjc-b,binding.xjb</extraarg>
            <extraarg>-xjc-Xts</extraarg>
          </extraargs> 
        </wsdlOption>
      </wsdlOptions>
    </configuration>
    <goals>
      <goal>wsdl2java</goal>
    </goals>
  </execution>
</executions>
<dependencies>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-xjc-ts</artifactId>
        <version>${cxf.version}</version>
     </dependency>
</dependencies>
</plugin>