Simon, does AwesomeCustomerImpl extends CustomerImpl, or do you have both
AwesomeCustomerImpl and CustomerImpl implementing Customer ?

If it is the former then returning and accepting CustomerImpl should work
but in the method accepting CustomerImpl you'll need to further cast to
AwesomeCustomerImpl or SuperAwesomeCustomerImpl. CXF will add xsi:type to
serialized data, see
http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-AutomaticJAXBElementconversionduringserialization

Cheers, Sergey

On Mon, Apr 18, 2011 at 1:53 PM, Sergey Beryozkin <[email protected]>wrote:

> Hi
>
>   On Sat, Apr 16, 2011 at 4:40 AM, [email protected] <
> [email protected]> 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
>>
>

Reply via email to