• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session bean and EJB container ?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic