Hi guys, I want to know how can I use Business Delegate Pattern in my client program(e.g JSP for that matter). I would really be thankful if u plz illustrate ur point thru code. One more doubt.... Can a Normal Java Bean be a Business Delegate Object?? If not then "WHY"??? What I am trying to say is, In a typical J2EE application architecture which uses MVC design pattern as follows: (JSP--->Java Bean--->Session Bean--->Entity Bean-->DB) Can I say the java bean used above is acting as a "Business Delegate Object", coz business delegate object lets u to decouple the presentation and business tier, which is what the above java bean is also doing??? Any comments on this??? Thanx in Advance :-) Jam
Absolutely, a java bean can be the business delegate, in fact that is the primary implementation. Part of what a business delegate achieves is to allow the presentation layer to be ignorant of where the business logic resides, how it's implemented, etc. Most business delegates connect use a ServiceLocator class to find the resources it communicates with on behalf of the presentation layer. This same business delegate, if engineered appropriately, can be used by a thick or thin client implementation.
Hi, Tx for ur reply,which cleared my doubt So as per to ur suggestion I am using Java Bean as a business delegate object which further uses service locator pattern to locate various JNDI services. One more doubt came to my mind.I would be thankful if u plz clarify that one too.It is as follows. In the Architecture which i mentioned in my first query (i.e JSP-->Java Bean--> Session Bean---> Entity Bean--> Data Base) Session bean in the above architecture have been used for Session facade, whose main purpose is to minimize the network level calls as much as possible. But since JSP, Java Bean, Session Bean and Entity Bean will be lying on the same server (e.g Weblogic, JSP and Java Bean in Web Container and Session bean and Entity Bean in EJB Container part of Weblogic). So as all the components are lying on the same server not on the two different machines on the network, I am unable to understand the use of session bean in the above architecture. Do u think is there any other reason for the use of Session Bean in the above architecture. Plz clarify Tx once again for ur reply Jam
The benefits of EJB are not simply to allow components to be distributed across many machines. Many other enterprise level services, which your components may or may not need are provided. They include transactions, security, resource managment (e.g. connections, object life cycle, etc.) Also with newer implementations of EJB there is the ability to make "local" calls that avoids some of the overhead associated with EJB. It is, however, still important for you to design the interface between your business delegate and any EJB's to be course grained (i.e. not "chatty"). If you have no need for any of those services and you don't think you'll need to either distribute the components or make them available to other components on the network, then you should consider not using EJB. It really depends upon the requirements of the system/business problem domain. Regards,