cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: handling polymorphism in @POST
Date Mon, 18 Apr 2011 12:53:39 GMT
Hi

On Sat, Apr 16, 2011 at 4:40 AM, joerg@kiegeland.com <joerg@kiegeland.com>wrote:

>
>> Can you send me a pointer to some examples?
>>
>
>
>  @Path("/")
>  class WebStore {
>    @POST
>    @Path("/customers/")
>    Response addCustomer(@XmlJavaTypeAdapter(CustomerImplAdapter.class)
> Customer c) {
>      ...
>    }
>  }
>
>
>
>
>
> public class CustomerImplAdapter extends XmlAdapter<CustomerImpl, Customer>
> {
>
>        @Override
>        public Customer unmarshal(CustomerImpl v) throws Exception {
>                return v;
>        }
>
>        @Override
>        public CustomerImpl marshal(Customer v) throws Exception {
>                return (CustomerImpl) v;
>        }
> }
>
>
> ... and annotate CustomerImpl with @XmlRootElement
>
> Alternatively, instead of adding
> @XmlJavaTypeAdapter(CustomerImplAdapter.class) to the parameter, you can add
> it to Customer inteface directly.
>
>
But how can we deal here with returning not only CustomerImpl but also
AwesomeCustomerImpl ?
Usually we can rely on xsi:type but this info is not available at the
adapter level

Cheers, Sergey


> Cheers,
> Joerg
>

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