Why the EJB implementation class should not implement RI


EJB design: Why the EJB implementation class should not implement RI

  1. HI! all
    I am just not able to find out the most convincing answer as to why the implementation class is not supposed to implement the Remote Interface. I know that it is strongly recommended of not doing so in the specification but has anyone figured out why?


  2. If the implementation class "implements" the remote interface of the bean , then the compiler will let you pass the "this" reference where you should pass the remote reference for the Bean (this typically involves a referrence to an interceptor object generated by the container which checks stuff, starts transaction and after that redirects to your bean).

    The handle for the Bean is accessed by context.getEJBObject() and you can pass that around to your clients where in a normal Java program you would pass "this".

    So, it is very error prone to implement the remote interface directly, but you can tentatively do that in order to check that you implemented all the methods, and in the final build you should remove the "implements MyEJBInterface" from the source code.
    If you coded the wright way then after you remove the implements clause, your application should still compile successfully.