0 Replies Latest reply on Sep 22, 2009 5:55 AM by gerbrand

    Returning EJB's from EJB's and transactions

    gerbrand

      Hello,

      I'm wondering about design of my application. We a lot of EJB (EJB3) using the @Stateless and @EJB tags. All EJB's are now local, but we're considering changing a few in remote interface.

      Quite a few EJB's return EJB's also and I wonder if that is correct in the first place, and secondly if this still works (and is correct) if the beans would become remote EJB's:

      @Stateless
      @Local
      class BeanABean implements BeanA
      {
      ..
      }
      
      @Stateless
      @Local
      class BeanBBean implements BeanB
      {
      @EJB
      BeanA beanA;
      
      BeanA getBeanA() { return beanA; }
      }
      


      Is the above code correct with regard to any JEE spec (I know from experience the code works). Secondly, if I use a BeanA that is returned from by the method of BeanB, is each operation done at BeanA done in a new transaction? Thirdly, what if both BeanA and BeanB become a remote interface (so getBeanA returns a remote interface), is the code still correct?

      All of the above might be somewhere in an article, but unfortunately I couldn't find anything that exactly answered my questions.