Forums Register Login

Session bean and EJB container ?

+Pie Number of slices to send: Send
do the EJB container create only one instance for the session bean and use threading? or a new instance for each client when a client invoke the session bean?
+Pie Number of slices to send: Send
Depends on the type of session bean.

For singleton session beans, there will be one instance in your application. This one instance may be accessed by several different threads. By default the container makes sure only one method may be accessed, but you can changed that using @Lock(LockType.READ) or @ConcurrencyManagement(ConcurrencyManagementType.BEAN).

For stateless session beans there are usually multiple instances. These may be reused (the container may pool some instances, and return instances from this pool), but each instance will be accessed by only one thread at a time.

Stateful session beans may be accessed from multiple threads at the same time, but the container must ensure that only one thread will have access at any given time. That means that if thread A calls method X of a stateful session bean, and thread B calls method Y of the same bean, then the container must make sure that the call to method X finishes for thread A before method Y will be called for thread B.
Let's go to the waterfront with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 581 times.
Similar Threads
How the second client knows the bean is free?
@PostConstruct confusion
Stateless ejbCreate can access Component
Stateless Session Bean - Life Cycle
My SCEA Part 1Study Notes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:07:51.