Discussions

EJB design: Servlet-Session Bean-Entity Bean or Servelt-Entity

  1. nowdays with a dominant container like WAS 5 Should we use Session Bean to mediate between my servlets and Entity Beans?
  2. Thinking ahead it might be better to use the SB in between. That way you can rely on local interfaces even if the web container would be separated from the EJB container for clustering/whatever. It is generally better to show the client (servlets) only the business interface (session beans) instead of exposing the domain objects (entity beans).
  3. Its always a good practice to never give clients direct access to Entity Beans. This is a good practice even if the client is a Servlet. We should always wrap access to EntityBeans in the form of a Session Facade and expose the Facade to the outside world(remote clients, and servlets/jsps)

     This would extremely help when you want to move your web tier away from your application tier
  4. There are many reasons for using facades, these are some of the others: -

    It is not good practise to have clients control transactions, as they often go for a coffee between starting and completing a business transaction, leaving resource tied up on the server. This is one of the other benefits of the facades.

    You don't want to expose your clients to your domain level, rather you insulate them, minimising change to the clietn if the domain changes.

    Security can be better managed at the facade level.

    See Floyds book for coverage of facades.