EJB inheritance / Component design


EJB design: EJB inheritance / Component design

  1. EJB inheritance / Component design (8 messages)

    Sorry for starting a new thread on this. But I believe this needs som new input.

    I've read some hundreds posts/articles about this subject - but not yet found a good example/solution. The EJB 1.1 spec (and 2.0) says it cannot be done. Maybe this is true?

    What I want to do is to make an J2EE component that can be expanded without having to make changes in the component.

    So, let's say, for an example:

    This is a Report component.
    To simplify, this component has got a CMP EJB called Report.

    Users of this component may want a more specialized Report - they want to make a new EJB - lets say TaxReport.

    How to implement this without component inheritance?

  2. You can use inheritance in ejb spec 1.1 or 2.0

    I have an open source example on this.

    - Please download the developer's manual of OpenUSS at:

    - Download the sourcecode at:

    - And read my comment on that stuffs (from OpenUSS
      mailinglist). This is how I want to reach a
      plug&play component architecture with ejb.
      It also uses inheritance.

    - You have to give me your e-mail address, if you
      want to have the uml diagram. It's easier to
      understand if you can take a look at the uml

    Have fun!

    Hi Mike,

    Thanx for your question. I sent you the developer
    manual of OpenUSS and the sourcecode for the
    newsgroup directly to your email address,
    so the other list member won't be angry with me
    (It's about 1,5 MB) ;-)

    For all of you, don't download the current version
    of OpenUSS. It's too old. Wait until 1st April
    and I'll update the download.

    This documentation could be a good base for
    developing the "plug-in" Extension Components.

    Important in this architecture is this structure:
    - Business Components (EJBs)
      + Foundation Components (BFC)
      + Extension Components (BEC)

    - Presentation Components (Enhydra's PO)
      + Foundation Components (PFC)
      + Extension Components (PEC)

    These are the steps writing an Business Extension
    Component (BEC):

    "Business Extension Components (BEC) - EJBs"
    This is the most important part. Because the reuse
    in this area should be the bigest part in the
    OpenUSS architecture.

    - First of all you just define your BEC totally
      independent from the BFC. Let's say we want
      to build a newsgroup component. It's important
      that you write this component as if no BFC existed.
      This is really important because I also want
      to develop this newsgroup component as
      a standalone component. A newsgroup component
      can be used overall on the web sites not only
      in a e-Learning platform.
    - After you finish your BEC (test, etc.)
      you create the "glue code" betweeen
      your BEC and the existed BFC.
      This means that you just use "inheritance".
      You can extend your BEC and put some properties to
      link it to the existed BFC.
    - That's it.

    You can see this in the UML diagram enclosed in
    this mail.

    Okay, it's sound really easy. The problem is that
    inheritance is not that easy by using EJBs. But
    actually it is also not sooo complicated ;-)

    These are the steps:
    - This is the code snippets of the BEC for the newsgroup
      component. You just first define the interface and
      afterwards you can write the home, bean and object
      classes respectively. (The sourcecode of this
      newsgroup is also included - Actually I call this
      component, discussion component ;-))

    public interface DiscussionItemBase {
      public String getSubject() throws RemoteException;
      public void setSubject(String subject) throws RemoteException;

    - You write the "glue code". In this case we want to link
      the Enrollment component (this is on of the Business
      Foundation Components). This means that we want
      to have a newsgroup for each enrollment.

    public interface DiscussionItem extends DiscussionItemBase {
      public Enrollment getEnrollment() throws RemoteException;
      public void setEnrollment(Enrollment enrollment) throws

      You have to write the home, bean and object classes for
      this glue code as well.
    That's it. It's really easy to write such a "plug-in"
    component within the EJB architecture.

    Some problems you encounter here:
    - If I delete an enrollment, how can I know
      that I also have to delete the newsgroup belongs
      to that enrollment? Or How can I know that
      there is a newsgroup already exists for
      this enrollment? Because this is a one direction
      relationship between the newsgroup/discussion
      and the enrollment. The enrollment component
      cannot know, what kind of Extension Components
      are installed at one time. I wonder whether
      an observer pattern can be done in this case?
    - I use the Facade Pattern for Session Beans and
      Entity Beans. Building a glue code for Session
      Beans is not that useful :-( You can see it
      in the sourcecode.

    With this architecture I can provide many standalone
    components to the OpenUSS Foundation Components.
    You can write any standalone Extension Components.
    After you finish it you can plug it in into
    the Foundation Components. You can take a ready
    to use component (must be an ejb one) as well and
    build the glue code to plug it into the Foundation

    I would like to hear your opinion about this and
    next time we can talk about the presentation layer,
    because the presentation layer should be reusable
    as well.

    Blasius Lofi Dewanto
    OpenUSS - Open University Support System
  3. Hi,

    I would also be interested in the UML diagram. My email-id is kgupta at covad dot com.

  4. EJB inheritance / Component design[ Go to top ]

    Your comments seem interesting, but I couldn't get the file at


    It's there a problem?


  5. EJB inheritance / Component design[ Go to top ]

    I can not get all the files you mentioned,any suggestion?

  6. hehe, my response won't be as long...

    Take a look at my reponse to previous thread

    If you have any questions I'll be happy to elaborate.

  7. my e-mail is:
    b dot e at pedersen dot cc

    I would be greatful for the UML diagrams.

  8. Done!

  9. Hi Lofi,

    Is it possible for you to send me the UML diagram as well as I also trying to figure out EJB inheritance..

    My email address is : murali dot muralidharan at etc dot co dot uk