EJB and Inheritance

Discussions

EJB design: EJB and Inheritance

  1. EJB and Inheritance (2 messages)

    Hi,
    i have a class, say called class1, and its a stateful session bean. i have another class, say class2 and it extends from class1. so class 2 should be an EJB! i have created a home and remote interface for both class1 and class2. the client tries to access the methods from class2 by using its remote interface. however it will not create a newInstance()...is this set up correct?
    thanks

    Threaded Messages (2)

  2. EJB and Inheritance[ Go to top ]

    From what I know now, EJB doesn't support inheritance. It means that you cannot create an EJB which inherits from another EJB. However, you can have an EJB that inherits from a standard class.
  3. EJB and Inheritance[ Go to top ]

    There is one issue, that we should consider, when we speak of interitance. Are we talking of inheritance of remote interfaces and the bean classes, or are we talking of a component inheriting (or "specializing") from another component?

    If you consider the former, it's definitely possible to create inheritance hierarchies between remote interfaces, and bean classes respectively. Since the underlying lnaguage is Java, you can do whatever type mangling that inheritance supports.

    However, when we consider "component inheritance" the story is different. Component inheritance means "component substitutability" - ability to substitute a more generalized component with a more specialized component - which means that an EJB container should be able to recognize substitutability - this is not possible.

    However, persoally I don't consider inheritance a natural fit for coarse-grained components.

    Subrahmanyam