wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes finalize method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "finalize method" Watch "finalize method" New topic
Author

finalize method

Soni Prasad
Ranch Hand

Joined: Mar 09, 2005
Posts: 97
Enterprise bean class must not define finalize() method why???


SCJP 1.4, SCBCD 1.3
Raju Mittal
Greenhorn

Joined: Jun 30, 2005
Posts: 4
Soni,

EJB container is managing the lifecycle of an ejb i.e. container is responsible for creation and removal of EJBS. Almost all type of ejbs are pooled. Untill a system exception occurs or remove is called (in case of SFSB), container is keeping a designated set of beans in the pools, increasing during peak loads and decreasing them during off-peak loads

So It doesn't make a sense to have Finalize method in EJBs.

I hope this helps.

Raju
KasiMurugan Ramasamy
Ranch Hand

Joined: Jan 30, 2005
Posts: 125
Hi,

Yes, almost all types of beans are pooled(except SFSB). The finalize method is called when JVM decided this object need more and also purpose the finalize method is to realse the resources(non java resources, like connection to db, file etc).

We have alternative methods for realsing the resources in ejb framework. The finalize method is not guaranteed to execute. But in our EJB framework, for entitybean instance level resource realsing method is unsetEntityContext, it is guaranteed to executed by container when the instance removing from the pooled state, likewise for Stateless bean also ejbRemove methods.

I hope this also help your understanding.

Thanks & Regards
Kasimurugan R.


Thanks & Regards
Kasimurugan (SCJP1.4, SCBCD1.3), Preparing SCWCD1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: finalize method