I am trying to copy the MVC design pattern. And this is what I do, I have a servlet which handles all the requests. In it, are the injected ejbs. So in this controller/servlet is declared 7 to 15 ejbs with the @EJB annotations.
I just want to ask if for example, 1 user calls the maincontroller/servlet. do the ejbs get injected only on that call or everytime a user calls the servlet do they get injected everytime? or the ejbs are injected the first time the servlet is created?
Injection is done when creating the object and since Servlet Container usually (but not mandatory – in case of single thread model) creates a single instance of a servlet and then serves the request in separate thread, the EJB in your case should be created once in case you are not using SingleThreadModel.