• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session facade

 
James J Xu
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In EJB tier, should we have to use Session Facade to access business objects such as entityEJB and sessionEJB? Or, could we access stateful sessionEJB directly from web-tier?

Thanks.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,

I find the following two paragraphs illuminating. They are from "Sun Certified Enterprise Architect for J2EE, Study Guide" by Paul Allen and Joseph Bambara.

J2EE Best Practices � Session Bean Fa�ade

The session bean fa�ade (SBF), shown in Figure 4-13, provides a simple, single point of entry to shared entity beans. It shields the client from complex entity bean relationships. The most obvious rationale for using session beans to abstract entity beans is that the approach also abstracts the structure of your data stores. The presumption is that you do not want to expose the inner workings of your application�s data store (such as the database tables and columns), or even the specifics of how that data is stored. In other words, letting users (potential hackers) know your database schema is not a good idea. Problems can arise when you allow direct access to the entity bean layer.

The methods in entity beans typically map directly to underlying fields in the data schema. This will become more important as service-based computing increases. Instead of providing complete applications, the J2EE specification (or Web Services: UDDI, SOAP) indicates that organizations are focusing more on components than on complete applications. Interchanging data components from enterprise A�s application with presentation components from enterprise B�s application is becoming the standard. As a result, it is unsafe to assume that only your enterprise will be accessing your business layer and EJBs. For these reasons, a sound design of the business layer can save trouble when beans you worked on must be accessible by a new business partner.

Regards,
Dan
 
James J Xu
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan,
Thanks for reply.
 
James J Xu
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If session facade talks with only one single entity bean, like AccountManagerSF used to manage CustomerEJB, should we just use a regular session bean like AccountManagerSLSB is enough? From best practice, it seems SF is used in managing the interaction between different beans.

Thanks.
 
Parag Doshi
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James J Xu:
If session facade talks with only one single entity bean, like AccountManagerSF used to manage CustomerEJB, should we just use a regular session bean like AccountManagerSLSB is enough? From best practice, it seems SF is used in managing the interaction between different beans.

Thanks.


Session Facades are generally used to abstract sub systems, complex entity relationships and inter dependencies between various entities in the system. The basic idea is that the web tier should never have access to the entity beans in the system. As the entity beans reflect the data model, its considered a bad practice to expose the interfaces of the entity beans to the web tier. It affects performance, maintainability and is also seen as a security risk to expose your database schema/model to the web tier.
Hence, you generally abstract the entity beans behind session beans. If you have multiple entity beans and complex inter-relationship between them, then its best to abstract them with session facade. Session facades are used to manage workflow or "processes".
If you have only one entity bean, then its best to either use a stateless or stateful session bean, as per the requirements of the system.

hope this answers your question..

parag
[ August 09, 2004: Message edited by: Parag Doshi ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic