This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

activate and passivate methods  RSS feed

 
Fred Abbot
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi how do these methods work
I understand the ejb container calls them directly
but isnt there some sort of code i have to put nto theses methods?
thanx
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a container decides that a particular entity bean instance has been sitting around in the container long enough, without being called upon, it might decide to reclaim that memory and 'passivate' the bean.

So the container calls ejbPassivate. I have seen some examples where the id field of the bean is set to null. But it could also be left empty.

When a client calls upon a passivated bean, then the container must call ejbActivate. It is pretty important in this method to put code there that would 'reinitialize' the id field of the bean.
eg:
But I have also seen examples where both of these methods are left blank. So I'm not sure how 'critical' they are.
 
Fred Abbot
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Curwen:
But I have also seen examples where both of these methods are left blank. So I'm not sure how 'critical' they are.

The reason is ejbActivate() and ejbPassivate() takes some of the resources for activation and passivation.So probably, it is better to improve on the memory requirements instead on activating and passivating the resources.
Hope this helps,
Sandeep
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!