File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Business Delegate/Session Facade Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Business Delegate/Session Facade Question" Watch "Business Delegate/Session Facade Question" New topic
Author

Business Delegate/Session Facade Question

Mark Hanfland
Greenhorn

Joined: Oct 19, 2004
Posts: 3
I am trying to do part two and am confused on the correct implementation of Business Delegate and Session Facade.

1) My main issue is that business delegate objects are not remote so do not support talking to the thick client. So where should the fat client connect to the server?

One idea would be for a stateful session bean before business delegate layer that acts as a controller. Seems strange looking with SessionBean(controller) to Biz Delegate to SessionBean(facade) to Data Access Layer.

Another idea was to scrap biz delegate and have the fat client talk to the session facade directly.

2) Should the Session Facade objects be stateless when using business delegate. I don't see in the J2ee pattterns examples any state management. If they are stateless then why use session facade with biz delegate? What is the advantage.

Thx,

Mark
Ramon Gill
Ranch Hand

Joined: May 15, 2003
Posts: 344
Mark,
Business Delegates can be remote and are used to link tiers. For example, a web tier can use a Business Delegate to link to a Session Facade on the the EJB tier. There is normally a one-to-one relationship between them.

Ray
A J Kumar
Ranch Hand

Joined: Oct 07, 2004
Posts: 35
Ramon,

IMO the swing client can directly use business delegate to interact with EJB Tier. However I have seen some posts where people are suggesting that Swing client should use XML/SOAP to connect to Front controller of web layer.

Could you/others please share your opinion/preference.

Thanks,
AJ
[ October 20, 2004: Message edited by: A J Kumar ]
Ramon Gill
Ranch Hand

Joined: May 15, 2003
Posts: 344
AJ,
Yes, I've also seen these. There is more than one way of solving the Swing Client problem. I've also seen suggestions using web services.

Personally, I'd have to discount Web Services as I don't know enough about them yet. Out of the other two (both are ok solutions) I'd go for the link to a separate Front Controller on the Web Tier, as I consider it a simpler solution for the client.

Ray
Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
Going by the Petstore implementation ,
U can simply make a URL connection from your client and call the business delegate which -->SLSB--> DAO (In this case the FFMS).

As Ramon mentioned there are many implmentations and u can choose any and I dont think u will be penalised for any implmentation as long as the requirement is met and explainations given.

HTH
Dhiren
A J Kumar
Ranch Hand

Joined: Oct 07, 2004
Posts: 35
Ramon - I am not sure if I understood when you say that you would go for the link to a separate front controller on the web tier. Could you please eloberate on that.

Dhiren - To be honest, I haven't focussed on the Swing client part of the Pet store so far. How about we just deploy the business delegate and service locator in the client tier. The swing client can invoke the business delegate and BD can use Service locator + JNDI to interact with EJB tier. I am not sure where would we use the URLConnection. Am I going in the right direction.

Any suggestions welcome...
[ October 20, 2004: Message edited by: A J Kumar ]
Mark Hanfland
Greenhorn

Joined: Oct 19, 2004
Posts: 3
Thanks for the thoughts. Sounds like this is acceptable

Swing Client->Biz Delegate (Stateful Session Bean)->Session Facade(Stateless Session Bean)->DAO

My web UI would be Controller(Servlet)->Command->ViewHelper->Biz Delegate->etc..
Parag Doshi
Ranch Hand

Joined: Jun 29, 2004
Posts: 317
From what I understand, there are atleast 2 choices to connect from the Swing client to the business tier:

1. Swing client connecting to the web tier by making a HTTPRequest (hence the use of URLConnection) to a different controller (possibly SwingController) on the web tier, thereby, using a common web tier.

or

2. The Swing client acts as a EJB CLient and has a BusinessDelegate (a POJO) which uses a ServiceLocator to connect to the business tier using RMI-IIOP, thereby, bypassing the web tier.

In both the instances the BusinessDelegate either lives on the ejb client tier (for swing) or the web tier (for webapp) and communicates via a SL with the business tier (which could have EJBActions, EJBController, SessionFacades etc etc).

Parag
Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
Thanks for the thoughts. Sounds like this is acceptable

Swing Client->Biz Delegate (Stateful Session Bean)->Session Facade(Stateless Session Bean)->DAO


Mark how would u control client authentication if there is no controller between the Biz delegate and client .?

Even if u had method level authentication how would u pass your principal?
Please give your suggestions.

Thanks
Dhiren
A J Kumar
Ranch Hand

Joined: Oct 07, 2004
Posts: 35
Originally posted by Dhiren Joshi:


Mark how would u control client authentication if there is no controller between the Biz delegate and client .?

Even if u had method level authentication how would u pass your principal?
Please give your suggestions.

Thanks
Dhiren


Dhiren,

As far as I understand, since the BD and SL are on the client tier, SL will communicate with EJB tier using RMI-IIOP that allows you to pass the user credentials.

HTH
AJ
A J Kumar
Ranch Hand

Joined: Oct 07, 2004
Posts: 35
Originally posted by Parag Doshi:
From what I understand, there are atleast 2 choices to connect from the Swing client to the business tier:

1. Swing client connecting to the web tier by making a HTTPRequest (hence the use of URLConnection) to a different controller (possibly SwingController) on the web tier, thereby, using a common web tier.

or

2. The Swing client acts as a EJB CLient and has a BusinessDelegate (a POJO) which uses a ServiceLocator to connect to the business tier using RMI-IIOP, thereby, bypassing the web tier.

In both the instances the BusinessDelegate either lives on the ejb client tier (for swing) or the web tier (for webapp) and communicates via a SL with the business tier (which could have EJBActions, EJBController, SessionFacades etc etc).

Parag



Parag,

That's very interesting. I have never thought about using URLConnection to connect to web tier from client tier. Could you please point me some documentation/link that describes this approach in detail.
Mark Hanfland
Greenhorn

Joined: Oct 19, 2004
Posts: 3
Updated Swing approach (many thanks to Parag)

Swing Client-->Biz Delegate (POJO Client Side)-->Front Controller(Stateful Session Server Side)--> SessionFacade(Stateless Session Server Side)-->DAO
Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
That's very interesting. I have never thought about using URLConnection to connect to web tier from client tier. Could you please point me some documentation/link that describes this approach in detail.


AJ,
Take a look at admin client in petstore.

The java files AdminRequestBD,ApplRequestProcessor,HttpPostPetStoreProxy

HTH
Dhiren
A J Kumar
Ranch Hand

Joined: Oct 07, 2004
Posts: 35
Thanks Dhiren. The information you provided was very helpful. And this brings up an interesting issue - Should there be a servlet filter between Swing based rich client and web-tier. The filter can be responsible for logging and security.

Any thought...
[ October 21, 2004: Message edited by: A J Kumar ]
Sudhansu Pati
Ranch Hand

Joined: Sep 23, 2003
Posts: 77
Thank you everyone for your contribution.

I would like to address this issue little differently. Have you looked at MVC architecture. The web tier can be best represented with a View Layer, Controller Layer and Model Layer. You can use a Controller Servlet not just for authentication and autorization, but also redirect the request to different JSPs, based on whatever screen the customer needs to see. The Contoller Servlet can use a Business Deligate to a Session Bean using a Service Locator.

You can follow the same MVC model for Swing client tier. There can be a Controller class, multiple swing view classes and and a model object. The Swing Controller class can use the Business Delegate to call Session Bean using a Service Locator. I don't see any need to make HTTP/HTTPs call to the Controller Servelt. That would probably add unnecessary overhead of another web tier. The compromise here is some redundant code.

The use of Business Deligate here is probably caching.Both Servlet and Swing Controller can use the same Business Delegate class to call the Session Bean. All business methods are handled by the Session Bean and all authentication, authorization, redirect is handled by the Controller class(Servlet and Swing).

Let me know if you see any issues with this design.


Sudhansu<br />SCJP, SCWCD, SCBCD, SCJD, SCEA, SCDJWS
A J Kumar
Ranch Hand

Joined: Oct 07, 2004
Posts: 35
This is what I am going with:

Swing/AWT client -> SwingRequestProcess -> SwingBD -> SL -> SF
Sudhansu Pati
Ranch Hand

Joined: Sep 23, 2003
Posts: 77
Hi AJ

=======================
This is what I am going with:

Swing/AWT client -> SwingRequestProcess -> SwingBD -> SL -> SF
=======================

This means that you are not going to use BD for web tier because you have specifically named the BD as SwingBD. In my original thought, I talked about using the same Business Delegate from both Web Tier and Swing Tier.

JSPs <-> ServletController <-> BD <-> Session Bean
Swing Client <-> SwingController <-> BD <-> Session Bean
sioud abla
Greenhorn

Joined: Oct 09, 2004
Posts: 4
Thank you,
According to this discussion, I think that the following is the best solution :

(1). JSP --> ServletController ---> (A)
(2). Swing ---> Swing Controller ---> (A)

(A): BD ----------> Stateless SB (fa´┐Żade) ---> DAO or CMP
|
|
SL

in (1) we use HTTPS and (2) is RMI/IIOP. the session is maintained by HTTPS and RMI/IIOP because they are statefull.

But I have questions about this solution:

1. Can I use RMI/IIOP even SSL is required?
2. How cas I access to a System like Perl, CGI,... with DAO? Can I use JNI or What?
Sudhansu Pati
Ranch Hand

Joined: Sep 23, 2003
Posts: 77

1. Can I use RMI/IIOP even SSL is required?
2. How cas I access to a System like Perl, CGI,... with DAO? Can I use JNI or What?


SSL is required for HTTP communications because the customer are going to use an untrusted network to comnunicate with the FBN system. When your Web later is communicating with the Business layer, that commnunication is RMI-IIOP and there is no need of SSL.

Also the Travel Agents don't need SSL to communicate with the FBN system because they will be using RMI-IIOP diretly from the client layer to commnicate with the Business layer.

You can use HTTPS with perl and CGI. No need for any JNIs.

Again, all these concepts are my opinions based on my experience and systems that I architected in the past. You can of course make your own choice and document those.
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
For application client, why dont you use 'Java Web Start' and pass the request/response in XML format.

JavaWebStart (Client Tier) --> SwingClientFilter (Servlet-Web Tier) --> SwingClientController (Servlet-Web Tier) --> SwingClientRequestProcessor (POJO-Web Tier) --> BusinessDelegate (common for web/swing)


And Service Locator sits in EJB Tier. This approach is given in WAF(Web Application Framework).

Here SwingClientFilter can handle security, logging and also forces user to login before accessing protected pages.

Any comments?


SCJP 1.5, SCEA, ICED (287,484,486)
Joseph Zhou
Ranch Hand

Joined: Aug 01, 2000
Posts: 129
I think Anil's suggestion is good. The Java client is located outside of the company's firewall, so the RMI/IIOP(or plus SSL enabled) will get it in.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Business Delegate/Session Facade Question