can a ejb inherit abstract Class?


EJB design: can a ejb inherit abstract Class?

  1. can a ejb inherit abstract Class? (4 messages)

    can a ejb inherit a abstract class?
  2. can a ejb inherit abstract Class?[ Go to top ]

    Sure, the bean implementation class can inherit from almost any class. Assuming a session bean, just make sure that the implementations of all methods in the corresponding remote interface get to that class, either through inheritance or as methods in the derived class itself.

    Pietari Laurila
  3. can a ejb inherit abstract Class?[ Go to top ]


    I had problems when i tried to do this due to the return types of the beans.
    Then base bean has a return type of one EJB Object and the sub class should have a return type relevant to that bean. But this doesn't work as java doesn't let you change the return type of a function inherited from another class (even if it is a sub class of the orignal return type).

    I found that i could get it to compile but when i can to deploy and use the bean it got really confused about which bean i was actually using and i had to cast the bean every time i returned it. (very annoying)

    If you come up with a solution please let me know as it would be very useful to be able to do this.
  4. You can't use inheritance with the ejbCreate() methods, but other than that you can. This is where most people miss the boat: ejbCreate methods are used BY THE CONTAINER to instantiate and link up the various remote/local pieces to an implementation of the class.

    This same holds doubly true when working with EntityBeans - you can get really messed up trying to use inheritance and the ejbCreate methods there.
  5. Hi,

     All Bean managed methods u can't inherit .. because some of them are Call back methods.