The standard paradigm I generally use for resource methods looks like this:
private Response fooMethod(String arg1, Object arg2, Foo arg3) {
ResponseBuilder responseBuilder =
Response.status(Response.Status.BAD_REQUEST);
// do a bunch of stuff
if (everythingOk)
responseBuilder = Response.ok(someObject);
}
return responseBuilder.build();
}
The 'someObject' marshals as XML or JSON or whatever I need to the
client just fine. In this one particular case in the same resource file,
I am calling 'fooMethod' directly and getting the Response object. I
need to figure out if the response was 200 or 400 (BAD_REQUEST) and if
200, see into the someObject. It looks to me as if ResponseImpl gives me
some of that. I was wondering if there was another, better, way to do this?
r
On 10/12/11 5:41 AM, Marek Potociar wrote:
> Not sure I understand why you need to check whether the Response is an instance of ResponseImpl. Can you elaborate?
>
> Btw. in general it is certainly a bad idea to do that. You would be making your code dependent on an implementation
> detail that can change at any time in future without any prior warning.
>
> Marek
>
>