--------Original Message-----
From: Eli Edwards [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 2:47 PM
To: jdjlist
Subject: [jdjlist] RE: Servlets Design QuestionYou could:- create a class called Action- contains method public Result doAction(request, response)- subclass Action for each of your actions and implement doAction method to do whatever needs to happen for that action.- In your servlet initialize a collection with the set of all Actions where each is accessible using the String name of the action as the key.- For the action String provided in a given request, get the Action from the collection and call its doAction method.That would simplify the servlet and modularize the actions. BTW, I'm not claiming credit for this idea, if you've seen it before. We use an approach like this in a big servlet application but with more layers of containment for various reasons.- Eli Edwards--------Original Message-----
From: Greg Nudelman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 2:10 PM
To: jdjlist
Cc: Greg Nudelman
Subject: [jdjlist] Servlets Design QuestionI'm rewamping an old system with Servlets and a Velocity templating engine. Servlets talk to the remote app server via a cleint-server protocol. A typical request then is as follows:
doService(request, response) { //"main method doGet/doPost"
if (action == "getXXX") {
Vector result = callRemoteGetXXX(request);
showUserXXX(result, request, response);} else if (action == "getYYY") {
//etc.
}
so basically, my main servlet becomes a very bloated file with doService(), as well as all of the callRemoteGetXXX(request) and showUserXXX(result, request, response) methods of which there are quite a few. What other accepted designs there are for placing the
callRemoteGetXXX(request) and showUserXXX(result, request, response) methods in separate files?
1) The old design had loosely grouped actions into types and had an adapter for each type that passed calls around in the context back to the servlet. All the response calls/formatting was handled in the root CustomServlet superclass.
Not a good idea IMHO.
2) create a RemoteCallManager DAO-type class, where all the (now static) callRemoteGetXXX(request) methods would live:
Vector result = RemoteCallManager.callRemoteGetXXX(request);
For handling of the response, maybe I can stuff the result Vector into the request object and then do some type of Context.forward(responseServletForAllTransactionsOfTypeRelatedToXXX, request, response);
For handling all those responses, they will be loosely grouped into response types and forwarded to 3-4 different "response only" servlets accordingly.
I like this better, but maybe there is another good way or some implementation/design tricks out there?
Any other ideas?
Thanks in advance.
Greg
P.S. we're on Apache/JServ 1.1/Velocity Java 1.4.1 Solaris
---
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
http://www.sys-con.com/fusetalk
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
http://www.sys-con.com/fusetalk
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
http://www.sys-con.com/fusetalk
