• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about the use of "final" in beans

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm new to EJB and am working my way through Head First EJB. I've noticed several times the authors point out that bean classes cannot be declared final, and that business methods in bean classes cannot be declared final. Can someone please explain the reason for this restriction? Is the container going to subclass the bean?

Thanks!

Robert
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm... good question.

I was searching in the spec, in chapter 8.2 you can see an example of all classes and interfaces that a container provider may create. In this example the AcmeCartBean extends the CartBean, therefore the CartBean can't be final.

7.10.2 of the spec:

7.10.2 Session bean class
...
� The class must be defined as public, must not be final, and must not be abstract.

==> it is guaranteed to the container provider that he CAN extend your beenclass (but it's not an obligation).

Severin
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bean classes must not be final in order to grant maximum freedom to the container providers when they have to integrate your beans into their container. The integration can be done in several ways. The three most common ways are delegation, extension and code generation. In case of extension, the container-specific classes must be able to extend from your bean class in order to integrate it in the container. Don't worry too much about this for the exam, you won't be tested on any container-specific stuff
 
What's that smell? I think this tiny ad may have stepped in something.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic