Hello all,

So far having a great experience with JAX-RS, hoping one of you folks can 
help me out here.

I have a generic service interface, like so:

public interface GenericService<T> {
        @POST
        @Consumes(MediaType.APPLICATION_JSON)
        public void doSomething(T obj);
}

And an implementation of the interface, like so:

@Path("/impl")
public class Impl implements GenericService<RealJAXBType> {
        public void doSomething(RealJAXBType obj) {
                // blah blah
        }
}

RealJAXBType is annotated as a JAXB XMLRootElement.  For information's 
sake, I'm using Apache Wink 1.1 with Jackson 1.5.5.

When I call the service exposed by the Wink servlet, Wink attempts to 
deserialize the passed JSON content to an HashMap of some description, not 
a RealJAXBType.  I assume that's because the @POST annotation is on the 
generic interface.  My guess is that Wink picks up the "class" of T, which 
is of course Object (as generic type T isn't scoped), and based on this, 
attempts a best-effort conversion into a HashMap, which is incompatible 
with the implementation's type of RealJAXBType.

I've verified this happens for an abstract superclass as well as an 
interface, so I guess it's to do with the annotation inheritance code.

This seems unintuitive - I'd certainly expect Wink to look at the 
implementation parameter's class when deciding what to attempt to 
deserialise the JSON content into.  Ideally, I'd like Wink to heed the 
type of the implementation.

What do you think?

--

Nick Maynard
Industry & Business Solutions
IBM United Kingdom Limited

x248240 / (+44) (0)1962 818240
Nick Maynard/UK/i...@ibmgb
[email protected]





Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU






Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to