cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jan.minarovi...@external.t-mobile.at
Subject Antwort: Re: Antwort: Re: Antwort: Re: customizing choice mapping [Virus checked]
Date Wed, 23 Jul 2008 15:54:46 GMT
Hi Dan,

as i know, it's jaxb problem that it generates lots of adapters even if 
they are all the same in case that parse/print methods are used.

I mentioned how my solution looks like and that it's working, because 
https://issues.apache.org/jira/browse/CXF-1620 says that "xjc:javaType 
adapter"  doesn't work but for me it works with 2.1.1.

so in my opnion there isn't reason to create jira entry for CXF .. maybe 
for JAXB.

best regards
jano




Daniel Kulp <dkulp@apache.org> 
07/23/2008 17:32
Bitte antworten an
users@cxf.apache.org


An
users@cxf.apache.org
Kopie

Thema
Re: Antwort: Re: Antwort: Re: customizing choice mapping  [Virus checked]







On Jul 23, 2008, at 3:36 AM, jan.minaroviech@external.t-mobile.at wrote:

> Hi Dan,
>
> huge one ..
> if you use parse methods, it'll generate adapter for you for each 
> datatype
> which needs to use this parse methods ... very ugly.
>

Uhg.....   didn't know that.  Hundreds of pretty much identical 
classes generated......

Can you log a JIRA and attach your code to it.   We cannot accept 
"patches and contributions" from the mail list.   We need to make sure 
the license checkbox is OK.    Lawyers......    :-)


Dan



> best regards
> jano
>
>
>
>
> Daniel Kulp <dkulp@apache.org>
> 07/22/2008 22:41
> Bitte antworten an
> users@cxf.apache.org
>
>
> An
> users@cxf.apache.org
> Kopie
>
> Thema
> Re: Antwort: Re: customizing choice mapping  [Virus checked]
>
>
>
>
>
>
>
> Is there any particular advantage to using the adapter stuff rather
> than the parse/printMethod stuff:
>
>  <jxb:globalBindings  xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>         <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
>
> parseMethod 
> ="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
>
> printMethod
> ="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
>   </jxb:globalBindings>
>
>
> Dan
>
>
>
>
> On Jul 22, 2008, at 4:30 PM, jan.minaroviech@external.t-mobile.at 
> wrote:
>
>> Hi Dan,
>>
>> yes, i was reading this .. but since it's experimental ;) i didn't
>> try.
>> But List<Serializable> is the same "nonsense" as List<JAXBElement>
>> which i
>> have without customization.
>>
>> btw. my solution was to modify wsdl for codegen process and to leave
>> there
>> only a sequence of these elements ;)
>>
>> note to CXF-1620
>> i'm using following external customization without problems:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <bindings version="2.1"
>>       xmlns="http://java.sun.com/xml/ns/jaxb"
>>       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>       xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>>>
>>
>>       <globalBindings>
>>               <xjc:javaType name="java.util.Calendar"
>> xmlType="xsd:date"
>>
>> adapter="xxx.common.jaxb.Date2CalendarAdapter" />
>>
>>               <xjc:javaType name="java.util.Calendar"
>> xmlType="xsd:time"
>>
>> adapter="xxx.common.jaxb.Time2CalendarAdapter" />
>>
>>               <xjc:javaType name="java.util.Calendar"
>> xmlType="xsd:dateTime"
>>
>> adapter="xxx.common.jaxb.DateTime2CalendarAdapter"
>> />
>>       </globalBindings>
>>
>> </bindings>
>>
>>
>> public class Date2CalendarAdapter extends XmlAdapter<String,
>> Calendar> {
>>
>>       public Calendar unmarshal(String value) {
>>       return (javax.xml.bind.DatatypeConverter.parseDate(value));
>>   }
>>
>>   public String marshal(Calendar value) {
>>       if (value == null) {
>>           return null;
>>       }
>>       return (javax.xml.bind.DatatypeConverter.printDate(value));
>>   }
>>
>> }
>>
>>
>> public class DateTime2CalendarAdapter extends XmlAdapter<String,
>> Calendar>
>> {
>>
>>       public Calendar unmarshal(String value) {
>>       return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
>>   }
>>
>>   public String marshal(Calendar value) {
>>       if (value == null) {
>>           return null;
>>       }
>>       return (javax.xml.bind.DatatypeConverter.printDateTime(value));
>>   }
>>
>> }
>>
>>
>> public class Time2CalendarAdapter extends XmlAdapter<String,
>> Calendar> {
>>
>>       public Calendar unmarshal(String value) {
>>       return (javax.xml.bind.DatatypeConverter.parseTime(value));
>>   }
>>
>>   public String marshal(Calendar value) {
>>       if (value == null) {
>>           return null;
>>       }
>>       return (javax.xml.bind.DatatypeConverter.printTime(value));
>>   }
>>
>> }
>>
>> best regards
>> jano
>>
>>
>>
>>
>> Daniel Kulp <dkulp@apache.org>
>> 07/22/2008 22:19
>> Bitte antworten an
>> users@cxf.apache.org
>>
>>
>> An
>> users@cxf.apache.org
>> Kopie
>>
>> Thema
>> Re: customizing choice mapping  [Virus checked]
>>
>>
>>
>>
>>
>>
>>
>> Just wanted to let you know that I found a solution to this.   :-)
>>
>> See:
>> https://jaxb.dev.java.net/2.1.2/docs/vendorCustomizations.html#simple
>>
>> Unfortunately, once you try that with CXF, you hit:
>> https://issues.apache.org/jira/browse/CXF-1620
>> unless you embedd the jaxb:globalBindings thing directly into the 
>> wsdl
>> itself rather than an external bindings file.
>>
>> I have a fix for that that I'm testing now.
>>
>> Unfortunately, the produced class is kind of ugly.   You just get a
>> "List<Serializable>" which I'm not exactly sure of it's contents.
>> Maybe JAXBElement objects?   Don't really know.  It at least doesn't
>> barf.    :-)
>>
>>
>> Dan
>>
>>
>>
>> On Jul 10, 2008, at 4:15 PM, Daniel Kulp wrote:
>>
>>>
>>> Just dug through the jaxb spec and I'm not seeing anything obvious.
>>> If the jaxb folks couldn't help, I'm not sure who would be able to
>>> help.  :-(
>>>
>>> I'm pretty sure the work the SXC folks are doing (sxc.codehaus.org)
>>> runs after the processing of the schema so that doesn't really
>>> help.   Not sure what to say.
>>>
>>> Dan
>>>
>>>
>>> On Jul 9, 2008, at 5:17 PM, jan.minaroviech@external.t-mobile.at
>>> wrote:
>>>
>>>>
>>>> Hello,
>>>>
>>>> i don't have answer from JAXB mailing list, and i cannot find a
>>>> clean solution. Maybe some here knows.
>>>>
>>>> Problem:
>>>>
>>>> i'm, using jaxb2.1.6 and i cannot find a solution for mapping of
>>>> one situation (see attached XSD). Without customization xjc
>>>> generates only list of jaxbElements. With customization i have 3 or
>>>> maybe 4 different errors depending on how do i try to map elements
>>>> to property names.
>>>>
>>>> I also found this
>> http://www.nabble.com/jaxb2---duplicate-element--issue- 
>> td16429810.html
>>>>
>>>> Does someone know how to map it? Atm. it's not important, if "the
>>>> same elements" in various branches of choice are mapped to the same
>>>> property or to different properties. But to have the same element
>>>> (name+type) mapped to one property is prefered way.
>>>>
>>>> Error message depends also on fact, if i'm trying to map the
>>>> elements with the same name+type to the same property name or not.
>>>> Some of errrors:
>>>> com.sun.istack.SAXParseException2: Element "{http://x.y.z}b" shows
>>>> up in more than one properties.
>>>> com.sun.istack.SAXParseException2: compiler was unable to honor
>>>> this property customization. It is attached to a wrong place, or
>>>> its inconsistent with other bindings. (this one is from the same
>>>> xsd as previous, i only changed customized property names to the
>>>> same for the same element name+type)
>>>> Other errors i had was about ambiguity and about property name
>>>> collision.
>>>>
>>>>
>>>> thank you for sharing your idea/solution
>>>>
>>>> best regards
>>>> jano
>>>>
>>>>
>>>>
>>>
>>> ---
>>> Daniel Kulp
>>> dkulp@apache.org
>>> http://www.dankulp.com/blog
>>>
>>>
>>>
>>>
>>
>> ---
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>>
>>
>>
>>
>>
>>
>>
>
> ---
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
>
>
>
>
>

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog








Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message