Discussions

EJB design: Using Entity Beans as plain java objects..

  1. Using Entity Beans as plain java objects.. (1 messages)

    Hello !
    Extending the idea from "Astral Cloning" pattern published
    on javaworld.com, I am trying to solve a design issue
    to achieve centralized implementation of business methods
    by using entity bean implementation in transactional
    and non-transactional contexts.

    Example patten involves following elements :
    Customer - Business Interface

    CustomerEJB implements Customer - Entity Bean

    CustomerSearchEJB - Stateless session bean to
                                      create readOnly ( non tran
                                      sactioanl non entity bean
                                      data by using entity bean
                                      implementation as plain
                                      java objects )
    CustomerUpdateService - Stateful session bean
                                      for updating Customer
                                      record. Uses CustomerEJB
                                      as entity bean.

    Now as a web client, if information is required
    for displaying a list of customers ( without any
    transactional context associate with it ), the client
    would call CustomerSearchEJB which would use CustomerEJB
    as a plain java object.

    If client or CustomerUpdateService needs to use
    CustomerEJB as entityBean, client would call appropriate
    CustomerHome lookup to get a remote handle for CustomerEJB.

    I have tested this pattern for basic funcationality and it
    works fine. This enables to have centralized implementation
    of business methods in entity bean independent of if
    it is used as "entity bean" or a plain java object with
    ability to sync state of entity bean with astral clone.

    Does anyone see any problems with this approach ??
    Thanks,
    -Sudarshan
  2. I have a problem, when I return my bean using the getAstralClone it gives me a classCastException, do you get this.

    I am using j2ee 1.3 cmp2.0.

    Thanks
    Glenn