aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Help... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Help..." Watch "Help..." New topic
Author

Help...

Vijay Govind
Greenhorn

Joined: Oct 18, 2006
Posts: 27
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
Arun Natarajan
Ranch Hand

Joined: Jul 21, 2006
Posts: 30
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

Joined: Oct 18, 2006
Posts: 27
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

Joined: Jul 21, 2006
Posts: 30
The connection must be closed and made null.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help...