a ejb can regard another ejb as super class or inherit it?


EJB programming & troubleshooting: a ejb can regard another ejb as super class or inherit it?

  1. i have many beans or plain java classes with inheritance structure,and i wanna take advantage of the legacy class structure and turn them into EJB,but i don't know whether ejbs can inherit each other.
    if that is impossible,what i can do for the parent classes and children classes

    thanks here in advance

  2.     Of course it can.

        define remote interface and home interface as usual, let your EJB bean class extends your legacy beans and implements EJB SessionBean/EntityBean interface. To be sure this bean class must obey to EJB rules(ejbXXXXX() methods and declare the all business methods in remote interface).

        sometimes you must amend your beans or plain java classes to suit EJB requirement.
  3. You will find that when you start doing this, your clients will not be able to use those EJBs polymorphically. You need a EJBHome that is specific to each EJB interface. You will need to resort to calling <EJBHome>.create() using reflection to get that EJB polymorphism.
  4. One major disadvantage of EJB component model is the lack of support for inheritance.

    You can only use inheritance for code reuse: you may inherit bean classes.

    If you want true inheritance you have to check JDO.