[jax-rs-spec users] [jsr339-experts] Re: InvocationCallback changing?

From: Bill Burke <>
Date: Wed, 27 Jun 2012 12:19:15 -0400

On 6/27/12 5:33 AM, Marek Potociar wrote:
> The problem is not with the generic entity type - the problem is with
> getting the generic callback type information as such so that the
> response data can be properly unmarshalled based on the callback generic
> type information.

Of course...Which is why we have GenericType for this type of scenario

> I didn't want to have all JAX-RS implementations copy the internal
> algorithms implemented in the GenericType.

Why would they need to do this? Just use GenericType.

> So I had to choose between
> changing it to an subclass of a GenericType and adding Class<?>
> getRawType() and Type getType() methods to the interface and let users
> implement it with every single InvocationCallback instance. I chose the
> first option as I assume users would not want to spend time implementing
> those methods over and over again. I also assume that in most cases the
> callback implementation will be an anonymous sub-class. Those few other
> cases where the callback would want to inherit from another class can be
> resolved by delegation.
> With the change, the type calculation is reused, users don't need to do
> anything extra to provide it, and the most common use case scenarios
> remain simple. I think this is the most efficient solution. Also, since
> the InvocationCallback conveys the response type information, the
> solution is also very natural.

I really really disagree. Abstract classes severely constrain your
options when class designing so what you are doing is really bad. How
would you handle generic types in a regular client request? Answer is,
you'd use a GenericType


Response response ="...").request().get();
List<Foo> list = response.readEntity(new GenericType<List<Foo>>(){});

Why is InvocationCallback a special case? So, do the same thing for

public class MyCallback implements InvocationCallback<Response>

    public void complete(Response response) {
       List<Foo> list = response.readEntity(new GenericType<List<Foo>>(){});


public class MyCallback implements InvocationCallback<Response>
    private Type type;
    public MyCallback(Type type)
       this.type = type;

    public void complete(Response response) {
       List<Foo> list = response.readEntity(new GenericType(type));

You're overthinking this... Get some sleep, have a coffee, maybe a
snack, kiss your wife, then revisit this problem and you'll see what I mean.


Bill Burke
JBoss, a division of Red Hat