• 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

Help...

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All

Please help me to get across the below confusions.

1) How does the container decide either to "passivate" or "to time out and kill a bean" when a stateful bean is in method ready state?

2) I understand it is container's sole decision to remove/kill a stateless bean. So When dealing with a "stateless session bean" should "remove()" be called by the client? I dont see remove() being called in the HFEJB examples. What exactly (and always) happens when the client calls remove() while dealing with a session beans?

3) Should the database connections etc be closed before ejbpassivate completes

Regards
Vijay
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) How does the container decide either to "passivate" or "to time out and kill a bean" when a stateful bean is in method ready state?
'Timeout/killing a bean' is related to inactivity on part of the bean, only a time factor is involved in this. 'Passivation' is primarily a memory related thing though there is a time factor involved in this too. Consider a server that is running an EJB application with a bunch of beans. As more and more stateful beans get created, the server's memory gets used up. At some point if the server finds itself short of memory to handle requests for new beans, it will look through the existing beans and pick the ones that have been most inactive and passivate them to free up memory. Different servers provide different options in configuring the passivation criteria.
Besides this the server will also be monitoring the beans to see which ones have been inactive for a period greater than the configured time-out period(say 20 minutes). Clients of beans that have been idle for more than this period are considred to be no longer using the application and so such beans will be killed. The server can kill beans that are already passivated too.
2) I understand it is container's sole decision to remove/kill a stateless bean. So When dealing with a "stateless session bean" should "remove()" be called by the client? I dont see remove() being called in the HFEJB examples. What exactly (and always) happens when the client calls remove() while dealing with a session beans?
Stateless session beans do not get a remove call even though the client may actually call the remove method. For statefull session beans remove is invoked when the client calls it and any code written here is executed.
3) Should the database connections etc be closed before ejbpassivate completes
ejbPassivate is called before the server passivates the bean, and the bean should be brought to a passivable state before it can be passivated. You would write code in the ejbPassivate to take care of non passivable data, such as database connections.
 
Vijay Govind
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arun

Thanks a lot and really appreciate your help on this. Just to clarify more, on #3, since you say "You would write code in the ejbPassivate to take care of non passivable data, such as database connections", do you agree that database connections should be closed or the connection reference should be set to null in the ejbPassivate() method?

Regards
vijay.
 
Arun Natarajan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The connection must be closed and made null.
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic