Hello everyone,
I really need your help to understand a thing I uncounsciously always considerated as obvious...but that's not really clear in my mind.
So, I knew for sure that a good characteristic of
EJB is the fact that the container is able to "scale" their instance number with respect
to actual request load it has to fulfill.
So, in a
servlet, I used to adopt this schema before EJB 3.1 adoption:
At each request, I used to lookup required SLSB and do some work. The more requests were send, the more the number of instances the container created
(I was able to verify this fact using my appserver admin console, which reported the number of ejbs created / destroyed...of course i was able to simulate
a variable number of request of service).
Now, with injection mechanism, I usually write:
So, in this last scenario, if I'm not wrong and I understood both servlets' and ejbs' lifecycle, there will be
a
single servlet instance which doGet, doPost methods are concurrentially executed by threads asociated
to the web requests, and in each request the
very same instance of MyEjb is accessed and used.
Is that wrong ? If not, it seems that with injection we eventually have a single instance of an ejb for each artifact
that requires a reference to it; if so, the property to scale with respect to the load is still valid ?
Please help me to understand.