|
From: Mike C. (mchack) <mc...@ci...> - 2008-10-09 14:38:33
|
I was wondering if the following pattern is supported, don't think so
but I may be missing something.
I would like to have a generic class wrap all my REST responses.
@GET
@Path(/somepath)
public GenericWrapper someMethod()
{
ResponseObject response = New ResponseObject();
return new GenericWrapper<response>(response);
}
The ResponseObject extends BasicResponse and is also annoted with JAX-B
@XmlRootEntity.
@XmlRootEntity
public class GenericWrapper<T extends BasicResponse>
{
String commondata;
String othercommondata;
String resultcode;
................
T response;
public GenericWrapper(T response)
{
this.response = response;
}
}
This way it simplifes the number of concrete classes needed for
different response types. I don't think this works. Is there another
pattern for this or is it reasonable for the framework to examine the
generics definition and search out the classes that extend BasicResponse
that have JAX-B annotations so proper marshalling can occur?
thanks
Mike Chack
O: +1 408.526.4639
M: +1 408.504.6594
mc...@ci...
|