maven-cxf-codegen-plugin using Jaxb binding to add inheritance for all generated classes
Asked Answered
I

2

5

I am using Apache CXF's cxf-codegen-plugin to turn a wsdl into java objects. I specified a binding file to add additional jaxb processing. I want all of these files to inherit from an interface (or extend an abstract class).

My problem is that while I can get this to work with one generated file using

<jaxb:bindings node="xsd:complexType[@name='sampleObj'] ">
        <inheritance:implements>example.Dao</inheritance:implements>
    </jaxb:bindings>

which will make sampleObj implement example.Dao. I do not know how to get this to process for all of my complex types (generated classes). Without repeating the above binding for every class (>100)

I tried,

 <jaxb:bindings  multiple="true" node="//xsd:compexType[@name='*'] ">

but it does not work.

Here is my maven plugin, if it helps:

 <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-resources</id>
                    <phase>process-resources</phase>
                    <configuration>
                        <sourceRoot>${project.build.directory}/generated/</sourceRoot>
                                               <wsdlOptions>
                            <wsdlOption>

                                <wsdl>${wsdl_location}</wsdl>
                                <wsdlLocation>classpath:wsdl.wsdl</wsdlLocation>

                                <!--<wsdlLocation>classpath:wsdl.wsdl</wsdlLocation>-->
                                <extraargs>
                                    <extraarg>-autoNameResolution</extraarg>
                                    <extraarg>-xjc-Xfluent-api</extraarg>
                                    <extraarg>-xjc-Xbg</extraarg>
                                    <extraarg>-verbose</extraarg>
                                    <extraargs>-validate</extraargs>
                                    <extraargs>-mark-generated</extraargs>
                                          <extraargs>-xjc-Xinheritance</extraargs>
                                    <extraarg>-p</extraarg>
                                    <extraarg>com.example</extraarg>
                                </extraargs>

                                <bindingFiles>
                                      <bindingFile>${project.build.directory}\classes\jax-ws_binding.xjb</bindingFile>

                                </bindingFiles>
                            </wsdlOption>
                        </wsdlOptions>

                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-fluent-api</artifactId>
                    <version>3.0</version>
                </dependency>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics</artifactId>
                    <version>0.6.5</version>
                </dependency>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics-annotate</artifactId>
                    <version>0.6.5</version>
                </dependency>
                 <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics-runtime</artifactId>
                    <version>0.6.5</version>
                </dependency>

                <dependency>
                    <groupId>org.apache.cxf.xjcplugins</groupId>
                    <artifactId>cxf-xjc-boolean</artifactId>
                    <version>2.7.0</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-api</artifactId>
                    <version>${cxf.version}</version>
                </dependency>
            </dependencies>
        </plugin>

    </plugins>
Insignia answered 30/5, 2014 at 18:44 Comment(1)
I'd like to achieve the exact same as you.. did you find any answers?Rathbun
L
0

Try this

<jaxb:bindings node="xsd:complexType">
Lorianne answered 15/7, 2014 at 2:36 Comment(0)
R
0

Ahh, found it at last: add multiple="true" to the bindings tag:

<jaxb:bindings schemaLocation="../../../../contracts/src/main/resources/wsdl/ifx24.xsd">
    <jaxb:bindings node="xsd:complexType[contains(@name, 'Rq_Type')]" multiple="true">
        <inheritance:implements>hu.eir.ifx.IfxExchange</inheritance:implements>
    </jaxb:bindings>
</jaxb:bindings>
Rathbun answered 19/3, 2015 at 10:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.