[ 
https://issues.apache.org/jira/browse/CXF-9133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949212#comment-17949212
 ] 

Andriy Redko commented on CXF-9133:
-----------------------------------

[~vmeunier] CXF uses xjc under the hood, so it offers what the xjc support. You 
could switch to @XmlAccessorType(XmlAccessType.PROPERTY), just pass 
*-Xpropertyaccessors* to xjc, for example:

    <configuration>
              <fork>true</fork>
              <wsdlOptions>
                <wsdlOption>
                  <wsdl>src/main/wsdl/HelloWorld.wsdl</wsdl>
                   <extraargs>
                        <extraarg>-xjc-Xpropertyaccessors</extraarg>
                    </extraargs> 
                </wsdlOption>
              </wsdlOptions>
            </configuration>


> WSDL2Java with JAXB
> -------------------
>
>                 Key: CXF-9133
>                 URL: https://issues.apache.org/jira/browse/CXF-9133
>             Project: CXF
>          Issue Type: Improvement
>    Affects Versions: 4.1.1
>            Reporter: Vincent Meunier
>            Priority: Major
>
> Hello
> We are using cxf maven plugin to generate our services and DTOs from WSDL and 
> XSD.
> It generates JAXB jakarta annotations as expected since the version 4.x. 
> We use an ObjectMapper (jackson) to serialize and deserialize those DTO, and 
> we try as much as we can to avoid the use of the Reflection API in Java.
> But at the moment, the DTO generated via CXF annotates every class with 
> *@XmlAccessorType(XmlAccessType.FIELD)* 
>  
> This forces the libraries that read it, to use the fields directly (which are 
> protected), and we have to use some JVM options --add-opens and so on, in 
> order to make it work. If we wanted to use the get/set, the correct 
> annotation would be *@XmlAccessorType(XmlAccessType.PROPERTY)* - or maybe 
> even better, 
> *@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER).* 
> If i'm not mistaken, it appears we are stuck at the moment, since there is no 
> way to customize the plugin in a way to make it change this specific 
> annotation.
>  
> In my opinion, we should offer the possibility to users to be able to 
> annotate how they want if the default value does not fit their needs.
>  
>  
> Exemple of a class generated : 
>  
>  
> {code:java}
> @XmlAccessorType(XmlAccessType.PROPERTY)
> @XmlType(name = "someClass", propOrder = {
> "oneString",
> "twoString"
> })
> public class SomeClass {     
>   @XmlElement(required = true)
>   @NotNull
>   @Valid
>   protected String oneString;
>   
>   @XmlElement(required = true)
>   @NotNull
>   @Valid
>   protected String twoString; 
>   
>   // get/set
> }{code}
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to