开发者

Returning superclass of return type from remote EJB method

Let's say I have remote interface A:

@Remote
public interface A {
  public Response doSomething();
}

And implementation:

@Stateless
public class B implements A {
  public BeeResponse doSomething() {...}
}

Where:

  • BeeResponse extends Response.
  • Response is located in the EJB-API jar and BeeResponse is in the implementation jar.
  • Response and BeeResponse have different se开发者_如何学编程rialVersionUID.

My assumption is that the unmarshalling of the response from B will fail, am I correct?


Well I tested this running in OpenEJB and it seems to behave as I predicted, the client does not understand the response from the Bean, since the BeeResponse class is missing from the client system.

It works until the point where the client starts to deserialize the response. However the serial version UID does not have any affect here because the client is unable to even create the class.

All this makes perfect sense now, but I was kind of "hoping" there would be some kind of magic that would make it work :-)


Since Java 5, this is allowed, so it should work. I suggest to give it a try and come back if you get an error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜