0

I have for example a WSDL definition construct like this:

     <xsd:simpleType name="MyDayType">
        <xsd:restriction base="xsd:string">
           <xsd:enumeration value="Sat"/>
           <xsd:enumeration value="Wed"/>
        </xsd:restriction>
     </xsd:simpleType>

And then you have some other object with for example:

     <xsd:complexType name="MyEntity">
        <xsd:sequence>
           <xsd:element name="dayType" type="v:MyDayType" minOccurs="1" maxOccurs="unbounded"/>
        </xsd:sequence>
     </xsd:complexType>

Now if I use the cxf-codegen-plugin, it will generate an enum "MyDayType" and references it in the "MyEntity" class. Usually this is exactly what you want.

However in my case I cannot use the enum as I am restricted in the way the generated Java code is used later on. So I would like that CXF generate strings instead of enums. So it simply maps all occurrence of this type in other objects to a string. In my example instead of:

public class MyEntity {
  protected List<MyEntity> dayType;
  /** Getters(/Setters) **/
}

I would like to have:

public class MyEntity {
  protected List<String> dayType;
  /** Getters(/Setters) **/
}

How can I achieve this? I would rather prefer some way of doing that without writing my own custom jaxb plugin.

seba.wagner
  • 3,800
  • 4
  • 28
  • 52

1 Answers1

0

I found a way to cheat myself to what I want. There is a config where you can set a value how much is the longest parameter name for an enum. If the enum contains value's that exceed this value, CXF will generate strings instead of enums.

I simply set this value to 1, so that every enum is bigger then the limit.

There is a description on how to set the value here: https://stackoverflow.com/a/12779608/1448704

Community
  • 1
  • 1
seba.wagner
  • 3,800
  • 4
  • 28
  • 52