Forums Register Login

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

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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?
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 759 times.
Similar Threads
Why final keyword is accepted with private?
Doubt on Modifiers
abstract class question
constant declarations - public final static
Constructor
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:28:47.