File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stateless Session Bean and remove()

 
Shreyas Reddy
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a stateless session bean doesn't really care when remove() is called, and as per page 282 of HFE nothing happens to the bean when client calls remove(), how come an exception is thrown if the client tries to use the EJB reference after removing the bean? Isn't removing the bean same as calling remove on the bean?

I have a home ref
I call create on home ref
I call bus method on component interface
then i call remove --> nothing really happens
i call bus method on component interface --> does this throw an exception?
thx,
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahhh... this is a good question.

When the client calls remove() on a stateless bean (or remove(Handle) on the remote home interface for a stateless ean), the Container doesn't care from the bean object's perspective... in other words, the Container isn't going to kill the bean simply because the client said to remove it.
(As opposed to with StateFUL beans where the Container WILL kill the bean as a result of the client saying remove(), since that stateful bean has no meaningful life except for with that one client).

But... the Container DOES acknowledge that the CLIENT is done with that bean. So the Container keeps the bean alive, and the bean never even knows that any of the client's it has serviced are done with it, but the Container still knows which clients have said they were done.

In other words, when the client calls remove() on a stateFUL bean, the client says, "Kill the bean and I am done with it forever." When the client calls remove() on a stateLESS bean, the client says, "I am done with the bean forever". So the Container knows that this client has already said that he is done with the bean, and any attempt by that client to use that bean again means something is wrong with the logic of that client, so the Container complains.

And if the Container had been keeping any resources available for that client, those resources go away.

cheers,
Kathy
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic