• Post Reply Bookmark Topic Watch Topic
  • New Topic

Stateless vs Stateful Session Beans

 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I wanted to try and illustrate the difference between the two types of beans for myself, so I created a couple of classes and remote interfaces as follows:


I then exposed the call() methods through a web service and invoked each of them four times. My output (in the Glassfish log) was as follows:

INFO: Stateless bean: 1
INFO: Stateful bean: 1
INFO: Stateless bean: 2
INFO: Stateful bean: 2
INFO: Stateless bean: 3
INFO: Stateful bean: 3
INFO: Stateless bean: 4
INFO: Stateful bean: 4


I was expecting the stateful bean's counter to be incremented with each call, but I didn't expect the stateless bean to do the same - I thought that it would essentially lose track of whatever state it was in (i.e. that it would be lost after being invoked, and that the next call would get a new instance). What am I missing?

Cheers,
Riaan
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone?
 
Ragavan Natarajan
Greenhorn
Posts: 1
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thank you Ragavan, and welcome to JavaRanch!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!