• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Session Bean cannot be final?

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone tell me whether the session bean class can be final? If not, what should I do if I do not want it to be inherited?
Thanks.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to the spec (7.10.2 ) session beans class cannot be declared final, or abstract.
Dilli
 
Li Xin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But what is the reason? Is it because the container will extend teh bean class?
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the reason is simply to enjoy the benefits of inheritance. If you want to make another bean which has similar properties as a current bean except some additional methods then inheriting the existing bean makes life easy.
Also remember class inheritance is possible in beans but inheriting the beanness is not yet allowed. See HFE Pg 186.
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Java Xml" and "Sudhir",
Thanks for joining JavaRanch, but could you take a quick look at the naming policy and edit your profile accordingly.
Sudhir, the reason I included you in this message is that we require both first and last names.
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The important thing to remember with the EJB spec is that it is designed not just for programmers writing apps (bean providers), but also for container vendors. With Sun's approach to java we are living in an object-oriented world, which means object-oriented development options should be available to the container vendors. Consider the following remote component interface and stateful session bean implementation class:

Amongst the various things the container needs to do is create an EJBObject to mediate access to the bean instance. The spec doesn't mandate how this is done, but a possible solution for stateful (not stateless) session beans would be for the container to generate a class at deployment time like:

Inheritance in this case would be used as a code sharing mechanism. Sometimes that isn't a great approach, but you could make a reasonable case that this use of it wouldn't seriously violate LSP (liskov substitution principle).
Of course, bottom line, the practical answer is "you don't use finalize because the spec says not to, and the spec is the agreement everybody has in common".
[ February 07, 2004: Message edited by: Reid M. Pinchback ]
 
Beauty is in the eye of the tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic