• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reason behind why we could not declare final keyword for the methods in the bean clas

 
NareshAnkuskani Kumar
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While going through the HJEJB i found that most of the methods in the bean class must not be declared with final keyword. I would like to know the reason behind why we could not declare final keyword?
 
Amresh Singh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Container creates its own implementation classes which extend our bean and interfaces.

For example container creates Home and EJB object stub for the Home and Component interfaces we create. If we declare methods using final keyword, container won't be able to implement your methods. That's why spec doesn't allow you to use final keyword with most of the methods which container implements in the classes generated by it.

Same logic applies to bean class also. Take example of CMP bean. the actual implementation of our create, remove, find and business methods is provided by container in a class which extends our bean class.


hth
Amresh
 
NareshAnkuskani Kumar
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while reading the ejb spec i came across a statement that in case of stateful session beans 'ejbCreate' method must not be declared with 'final' keyword? To my knowledge, we code the ejbCreate method to initialize the state of the bean then why not i declare the method with 'final' keyword?

Also the ejbObject & ejbHome is implemented by the container & all we know that methods as part of interface (eg. EJBObject & EJBHome) are by default abstract and not final?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic