aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes Finalize() method in the bean class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Finalize() method in the bean class" Watch "Finalize() method in the bean class" New topic
Author

Finalize() method in the bean class

Karen Young
Greenhorn

Joined: Jan 12, 2005
Posts: 10
Hi All,

I've been reading up on EJB technology and the book says a bean class cannot define the finalize() method. Why? Can I define the finalize() method if I have a finally{} block in there that calls super.finalize()? Thank you.
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
Hi,

finalize() should not be declared as it may or may not be invoked.

When a bean is removed from instance pool , its unsetEntityContext() is invoked- this method let the bean release any resources it helds before this bean instance is garbage collected. finalize() may or may not be invoked because it depends on each EJB vendor's own implementation about the way of destroying the bean instance.
Karen Young
Greenhorn

Joined: Jan 12, 2005
Posts: 10
But, does that mean the compiler will not allow an empty finalize() method? Or is it just good practice not to hane a finalize method? Thank you.
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
I have never tried using finalize() in bean so don't know if compiler rejects it or not. Moreover the way I read in EJBbook, it specifies that finalize() implementation is vendor specific. It depends on EJB container/server that you are using and in general its a good practice not to have this method in Bean.
Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
I would discourage using finalize() for anything.

Zak
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Finalize() method in the bean class
 
Similar Threads
Rules for the Bean class
requirements for session beans
finalize method
finalize method
finalize()