Design: JSP->Servlet-> BusinessDelegate / Session - >Entity Flow


EJB design: Design: JSP->Servlet-> BusinessDelegate / Session - >Entity Flow

  1. Hello Guys,

    I want to know whether the Design I have done is good or not... Suggessions are welcome.

    I want to design a J2EE system and my approach is :
    1. a Screen Preferably JSP: User clicks add Customer
    2. Request goes to MaintainCustomerServlet which gets respective Business Delegate and
    3. Business Delegate Calls Entity Bean.

    Now other approach is Business Delegate calls Session Facade to Entity Bean.
    I am using EJB 2.0 Spec. Remote Interface for Entity Beans

    Which approach is Good?

    Please advice.


  2. I forgot to add ServiceLocator pattern after Business Delegate as a step. BD will get Entity home from ServiceLocator.

    Regards, Raj
  3. I would definately go with the Facade pattern. First of all it abstracts the access to the Entity Beans, actually making a system boundary to your persistent object model.

    Furthermore...if you had other clients (than JSPs) you could access the exact same Facade.

    I have done this in a real-life application and it works like a charm. I this application I have another "client", a WebService, in front of Facade and BusinessDelegate...

    Think of the Facade as a system boundary, an inteface.

  4. Can I use Business Delegate as well as Session Bean? e.g. Business Delegate talks to Session facade and then Facade talks to Entity Bean. Will it create over head?

    What do you say?
  5. Using the idea of loose coupling have one more layer between servlet and business delegate- A handler which handles appropriate events or actions.This way your servlet just acts as a controller.
    It is highly recommended to have business delegate and Session facade (SLSB) before persistence layer or business controller.Delegate caches the lookups to facade(avoiding expensive JNDI lookups) and facade acting as a boundry of abstraction,provides high scalabality.The facade now passes the control to another handler, which then calls Session bean -> entity bean or DAO as per your requirement.
  6. Hi Jyot,
    Thanks for the Comments and Suggessions..