JBoss Community

How does a @EJB dependency injection work on a Stateless Bean? Will that injected class behave like an instance variable in that stateless session bean?

created by Adheep M in EJB3 - View the full discussion

Hi guys,

 

I have this question on the latest  version EJB 3.1 has the "@EJB" annotation which is used for the dependency injection.

I have two stateless session bean and a singleton bean

 

@Stateless
public class PrimaryStatelessBean {
 
     @EJB
     SecodaryStatelessBean secondaryStatelessBean;
 
     @EJB
     SimpleSingletonBean simpleSingletonBean;
 
     public String processRequest ( ) {
          
          .....
          secondaryStatelessBean.getValue();
          simpleSingletonBean.getAnotherValue();
          ....
     }
 
}

How does the @EJB annotation work, will the injected class behave like an Instance variable of the PrimaryStatelssBean ? :-/

Reply to this message by going to Community

Start a new discussion in EJB3 at Community