JAX-RS generic response and interface proxy

Go To StackoverFlow.com

3

is there any way how to return generic describing entity type with the JAX-RS Response? Something like REST-Easy ClientReponse but JAX-RS standard and not implementation-specific class.

The thing is I want to call my REST service via its shared interface (created by some proxy provider) and returning only object does not allow add information I need. E.g. for creating resource via POST, I would like to return also URL to newly created resource and so on. Returing simple Response does not show what type of entity is stored within such response.

Response<MyObject> getMyObject(@PathParam("id" Integer id)

So far it seems that I will have to return simple Response and then create adapter which will simply call Response.getEntity(.class)

2012-04-04 21:10
by zdenda.online


1

There is probably no such option...

2012-09-18 11:39
by zdenda.online
It is a pity. I was looking for the same generic Response and I think it would be a great improvement to JAX-RS 2. - Guido 2012-11-14 17:44
yup, we can hope: - zdenda.online 2012-12-21 10:24


-1

GenericEntity allows you to return a generic. The actual type is held at runtime by GenericEntity, allowing the object to be serialized.

Here's a contrived example of how it can be used.

GenericEntity entity = new GenericEntity<Employee>(new Employee());
return Response.ok(entity).build();
2013-03-06 05:05
by Jeremy Ross
IMO this does not solve the issue. How should look method signature of shared interface? I know how to pass the entity to response, there is not needed to use GenericEntity. The client simply needs the Response object (e.g. to check various headers and so) but it would be also fine to get generic of return type from such response - zdenda.online 2013-03-12 14:38
Ads