• Post Reply Bookmark Topic Watch Topic
  • New Topic

finalize() method in EJB  RSS feed

 
AparnaYadav Yadav
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anyone plz tell me why we can't define finalize() method in EJB & we have to define a public constructor in case of MDB.

Thanks in advance.

Aparna.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by AparnaYadav Yadav:
Hi,
Can anyone plz tell me why we can't define finalize() method in EJB & we have to define a public constructor in case of MDB.

Thanks in advance.

Aparna.


Finalize method is discouraged because it may be never be called.

In MDB, it is container which handles the life cycle of MDB and it is also responsible for pooling the instances. Public no-arg constructor is required so that the container create instances and pool them.
 
AparnaYadav Yadav
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Pradip,
I am reffering to EJB spec. for MDB there is a explicit line specifying not to override finalize() method for MDB. but this is not mentioned for any other type of EJB.

Thanks,
Aparna
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by AparnaYadav Yadav:
Hello Pradip,
I am reffering to EJB spec. for MDB there is a explicit line specifying not to override finalize() method for MDB. but this is not mentioned for any other type of EJB.

Thanks,
Aparna


I Checked the spec again, the finalize should not be overriden for any EJB bean classes. Search for "finalize" in the pdf document.
 
Sai Krishna Chitta
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

According to Spec one should not override finalize method in any type of bean. It is the responsibility of Container to take care of GC. And moreover, EJBClient dealing with Stub of the Bean.

[ October 21, 2005: Message edited by: Sai Krishna Chitta ]
[ October 21, 2005: Message edited by: Sai Krishna Chitta ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!