• 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

Stateful session bean applications.

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am trying to think of an application or some scenarios where I would use stateful session beans. I know that when I need to maintain state I need staeful bean, but a more real world example would help me understand better. Almost always I feel a stateless session bean would suffice. Could someone who has used stateful session beans give me an example of where you used stateful session beans?

THanks.
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Online Shopping. How would you implement a shopping cart?
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An HTTP session would normally be a good alternative for session management for web apps.

It's generally true to say that there usually is no pressing case to use SFSBs and that you would use SLSBs in most cases.
 
Arun
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Satish and Roger. As Roger says, I would implement a shopping website with SLSB's. Store the items a shopper adds to a http session and finally when he checks out, call a business method on a SLSB to do all the business logic. If i took the SFSB approach, for every item the shoppers adds to his cart I would be making RMI calls to some method in the SFSB, which is not that efficient.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another good reason to use HttpSession is that when a session is invalidated, you can do a cleanup in the valueUnbound() method should you have implemented the HttpSessionBindingListener interface.

Back to session beans: the big benefit of SLSBs is performance as they are pooled on server startup (and reused after the EJB method calls end), whereas SFSBs are created on client demand and are destroyed after use.
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would also use stateful SBs where it would be more expensive to re-create the state in a stateless SB for each method call - a poorly implemented stateless SB can be considerably less scaleable than a well implemented stateful SB.
 
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic