• 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

remove() method in stateful session bean

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a stateful session bean is passivated and remove() method is called by the client, will it be first activated or straight away destroyed
Thanks
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sangeeta,

You cannot call any method on a passivated bean.Passivated state means the bean is not active and is written to some temporary Storage to conserve resource.

Regards
Shiv
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You cannot call any method on a passivated bean.Passivated state means the bean is not active and is written to some temporary Storage to conserve resource.


This is not correct. The remove() method is treated by the container as a business method, so the container will activate the bean and then invoke ejbRemove() on it.
 
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Roger has written is right but then I think that it depends upon the container implementation. Although I am saying that the container will treat it as a business method but it doesn't make much sense to activate a bean and call remove on it. In case of entity beans it is because of cascade-delete that the container will activate the bean and will remove it.

But in stateful bean deserialize and then call ejbRemove doesn't make much sense as most of the time the code that will be in ejbRemove and ejbPassivate will be same to make sure that the code is always executed.

Sawan
 
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
It does not depend upon the container implementation, it is a requirement. Is remove() a container callback? No. Is remove() a business method? Yes. (Ask yourself if remove() begins with "ejb", it does not so it must be a business method as the only rule concerning business method names for entity and session beans is that they must not begin with "ejb".)

Also, it makes perfect sense for a container to always activate a passivated bean in order to invoke ejbRemove() on it. Just think of the confusion if your code in ejbRemove() may or may not be run depending on whether the bean instance happened to be passivated or not.
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Roger has written is right but then I think that it depends upon the container implementation

My point was that it should have been left over to the container provider and in hurry i wrote something else [the above lines in my previous post].


Also, it makes perfect sense for a container to always activate a passivated bean in order to invoke ejbRemove() on it. Just think of the confusion if your code in ejbRemove() may or may not be run depending on whether the bean instance happened to be passivated or not.

There are many cases when the ejbRemove() may not be called like bean times out in passivated state. The above case won't be the only scenario. I was just thinking from the point of view of the performance that it doesn't makes much sense to activate the passivated bean and remove it. Its a performance kill.

Anyways if this is what specs says then there is nothing much to write


sawan
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
reply
    Bookmark Topic Watch Topic
  • New Topic