JAX-RS generic response and proxy
Is there a way to return a generic, descriptive object type with a JAX-RS response? Something like REST-Easy ClientReponse, but JAX-RS standard, not implementation specific class.
The thing is, I want to call my REST service through my generic interface (generated by some proxy provider) and returning only an object prevents me from adding the information I need. For example. to create a resource via POST, I would like to return the url to the newly created resource and so on. Keeping a simple answer does not reveal what type of object is stored in such a response.
Response<MyObject> getMyObject(@PathParam("id" Integer id)
So far, it seems to me that I will need to return a simple response and then create an adapter that will just call Response.getEntity (.class)
source to share
GenericEntity allows you to get back the generic. The actual type is stored at runtime GenericEntity, which allows the object to be serialized.
Here's a contrived example of how you can use it.
GenericEntity entity = new GenericEntity<Employee>(new Employee());
return Response.ok(entity).build();
source to share