2 Replies Latest reply on Feb 3, 2008 2:57 PM by Sebastien Degardin

    Session beans (annotated with @Name): @In or @EJB

    Kenneth Christensen Novice

      I know the EJB container takes care of the injection when I'm using @EJB to inject a session bean (i.e. a seam component is not created).


      And I also know Seam takes care of the injection when I'm
      using @In(create = true) to inject a session bean (i.e. a seam component is created).


      What is the advantage of using @In instead of @EJB?


      BTW (hijacking my own thread :-)): I would be thankful, if someone could help me with this thread: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=129148

        • 1. Re: Session beans (annotated with @Name): @In or @EJB
          Kenneth Christensen Novice

          I know the EJB container takes care of the injection when I'm using @EJB to inject a session bean (i.e. a seam component is not created).

          i.e. a seam component is not created

          not true - SessionBeanInterceptor creates a Seam component if session bean was obtained by @EJB.


          But I still asking myself 'what is the advantage of using @In instead of @EJB?'

          • 2. Re: Session beans (annotated with @Name): @In or @EJB
            Sebastien Degardin Newbie

            Hi Kenneth,


            Here is what Seam Reference guide says :


            In all dependency injection implementations that
            we have seen, injection occurs when the component is constructed, and the reference does not subsequently
            change for the lifetime of the component instance. For stateless components, this is reasonable. From the point
            of view of a client, all instances of a particular stateless component are interchangeable. On the other hand,
            Seam emphasizes the use of stateful components. So traditional dependency injection is no longer a very useful
            construct
              (more on chapter 3.3 of the Seam Reference guide.)


            Also, @In provide any kind of Seam component, EJB, JavaBean, EntityManager, .... not only @EJB