File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes A simple query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "A simple query" Watch "A simple query" New topic
Author

A simple query

shalu sharma
Ranch Hand

Joined: Sep 09, 2002
Posts: 51
Hi,

Please tell me if one can create a bean class which extends another bean? After all in java one can create any class which is extending one single class and EJB is a java class file only. If not what could be the reason.

Thanks
Shalu
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
yes you can. you can extend another class - a class who is a child, directly or indirectly to a parent ejb class
Naren India
Greenhorn

Joined: Aug 29, 2005
Posts: 2
Extending just a class is always permitted in EJB but what really makes any sense to just a class extension in terms of inheritance in EJB? I guess it will be worth if an EJB extends another EJB to add-on some functionality and inherit all characteristics of the parent EJB (here all characteristics means many thing like EJB type, transactions, security etc) but an EJB is really not a single class so in true sense the inheritance in EJB is not supported by specification. Some day the true inheritance may be possible but not now.
shalu sharma
Ranch Hand

Joined: Sep 09, 2002
Posts: 51
Originally posted by Naren India:
I guess it will be worth if an EJB extends another EJB to add-on some functionality and inherit all characteristics of the parent EJB (here all characteristics means many thing like EJB type, transactions, security etc) but an EJB is really not a single class so in true sense the inheritance in EJB is not supported by specification.


yes i was talking about 1 ejb extending another ejb only.. if it is not supported by the specification then it means that this feature would not be supported by many app servers.

Here I would like to know which all vendors/app servers support this type of functionality and can u give me some example/scenario where there is a suitablity for type of inheritance.
S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
Hi

It is clearly given in the book (HF EJB) that you can extend a bean class from another class or bean class. It is plain old java inheritance. It will just do the normal inheritance and you cannot inherit beanness. Refer to the book. I couldnt remember the chapter name. I will tell you tomorrow.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, NEXT--->IBM XML
Naren India
Greenhorn

Joined: Aug 29, 2005
Posts: 2
Back to your question is there any app server that supports bean inheritance? Answer is NO because bean inheritance is not supported in EJB specification. Sure the specification does not prevent to use class inheritance. An EJB can extend a class but that's not some thing inheriting EJB or EJB's characteristics.
shalu sharma
Ranch Hand

Joined: Sep 09, 2002
Posts: 51
I came accross an interesting article about ejb inheritance. Pls check it out. would like to know the ranchers comment.

http://www.onjava.com/lpt/a/2589
Ahsan Jamil
Ranch Hand

Joined: Aug 24, 2001
Posts: 58
Hi,

Interesting debate,
Well, the thing is that, there are two things 1) What you can do according to Java specs 2) What you can do as per ejb specs

Although you can Inherit any class according to Java Specs but Ejb Specs doesnt say any thing about Inheritence of a bean.

This is an exam based on Ejb specification rather than Java Specification. (clearly mentioned in HF EJB).


Regards,<br /> <br />Ahsan Jamil<br />SCJP, SCWCD, IBM OOAD
Ganesh Krishnan
Ranch Hand

Joined: Sep 28, 2004
Posts: 42
Hi Shalu,

EJB being part of J2EE spec, does support inheritance... by saying that when u inherit the one bean CLASS in another, you can inherit the functionality, but not the 'UNDERLYING BEANESS' provided by it...

- Ganesh.
SCJP,SBCD,SCEA,BEA Certified Weblogic Administrator.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: A simple query