2 Replies Latest reply on Oct 1, 2010 1:36 AM by nsemchenkov

    DI in service MBean

    nsemchenkov

      Hi all

       

      I have a service bean (i.e. bean, annotated with @org.jboss.ejb3.annotation.Service)

       

      Is it safe to inject @Stateless EJB into such singleton bean? Does this mean that @Service bean will be linked to the same instance of @Stateless bean throughout all its life?

        • 1. Re: DI in service MBean
          jaikiran

          Nick Semchenkov wrote:

           

          Hi all

           

          I have a service bean (i.e. bean, annotated with @org.jboss.ejb3.annotation.Service)

          Which version of JBoss AS? If you are using AS 6.x then it's recommended not to use the now deprecated @Service and instead use the EJB3.1 spec based @Singleton.

           

          Nick Semchenkov wrote:

           

          Hi all

           

           

          Is it safe to inject @Stateless EJB into such singleton bean? Does this mean that @Service bean will be linked to the same instance of @Stateless bean throughout all its life?

          If you are injecting a @Stateless bean, that the instance selection for the @Stateless happens during invocation on the injected proxy. So it would not always end up on the same @Stateless instance.

          • 2. Re: DI in service MBean
            nsemchenkov

            Thanks for reply. I'm currently using the latest stable release - 5.1. It doesn't include support of EJB 3.1 singletons, so I'm forced to use @Service beans.