Hi,
I'm using JAX-RS and spring 3. I have a problem with inheritance on the receiving end of the service and I'm wondering if there is a way to work around this.
PHP Code:Types of beans sent
public class ParentVO{
String label;
}
public class ChildVO extends ParentVO{
String label;
int count;
}
client
ChildVO vo = new ChildVO();
vo.setLabel("Hello");
vo.setCount(1);
RequestObject request = new RequestObject();
request.setVO(vo);
ResponseObject response = importProxy.importContent(request);
I'm trying to work with a single importContent method in stead of creating one specific to eaach type of bean.PHP Code:public class RequestObject{
ParentVO vo;
}
Server JAX-RS client
@POST
@Path("/import/standard")
@Secured({"ROLE_WS","ROLE_ADMIN"})
@Produces("text/xml")
public ResponseObject importContent(RequestObject bean){
}
But "vo" is always of type ParentVO including when a ChildVO is sent.
Is there a way to do this with JAX-RS?
I've also tried the following with the same result.
PHP Code:client
ChildVO vo = new ChildVO();
vo.setLabel("Hello");
vo.setCount(1);
RequestObject<ChildVO> request = new RequestObject<ChildVO>();
request.setVO(vo);
ResponseObject response = importProxy.importContent(request);
ResponseObject response = importProxy.importChild(request);
In the case above both importContent and importChild produced a vo of type ParentVO, which surprised me.PHP Code:public class RequestObject<T extends ParentVO>{
T vo;
}
Server JAX-RS client
@POST
@Path("/import/standard")
@Secured({"ROLE_WS","ROLE_ADMIN"})
@Produces("text/xml")
public ResponseObject importContent(RequestObject bean){
}
@POST
@Path("/import/standard")
@Secured({"ROLE_WS","ROLE_ADMIN"})
@Produces("text/xml")
public ResponseObject importChild(RequestObject<ChildVO> bean){
}
Any suggestions? Primarily, I would like to avoid unique method signatures for each child.
Kind regards,
Marc


Reply With Quote