• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finalize()

 
Peter Warde
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know a Message-Driven bean cannot have a finalize() method, but is this true of Session and Entity beans?
 
Nileesha Bojjawar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the spec Page 95,199 and 324 None of the bean types must define the finalize() method in their bean class.

Cheers
 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Specs says finalize() is not allowed in any bean class.

Can some one please explain why is finalize() NOT allowed in any of Bean?
 
Nileesha Bojjawar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO,
finalize() method is used to do things you want to do just before the object is destroyed or garbage collected and for entity beans the container manages the lifecycle of the bean to the most extent and hencewe get all the security, transaciton managements etc and hence may be it must not be implemented by the bean provider for the container to have control of the resources. Also the way the container manages beans and pools is implementation specific. The jvm calls the finalize method on a object when it figures out that there are no more references to the object and in a remote scenario it cannot be figured out, and because EJBs are meant to be remote components you can never gaurantee that the objects reside in the same JVM and is totally based on the container implementation.

I might be totally worng in my thinking!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic