|
 |
pro_jsp thread: Chptr 6 - Synchonization problems?
Message #1 by "Michelle" <mpopovits@h...> on Thu, 24 May 2001 17:38:53
|
|
Hmmm, interesting question. A number of methods spring to mind:
* Merge process(), forward(), and getURL() into one larger
method. Easy but you lose the way the various different
concerns are divided between the methods. (This is the way
the Struts and WebWork frameworks do things.)
* A bit nastier: modify _dispatch() and getURL()'s signature so
that _dispatch() passes the request object to getURL(); you can
then use request attributes to pass values around. This feels ugly.
* Modify the Controller class so that it does more intelligent pooling
of event handlers, so that a particular handler instance will only be
accessed from one thread at a time. Sounds like hard work.
Richard Huss
Technical Architect, Wrox Press Ltd
richardh@w...
www.wrox.com
-----Original Message-----
From: Michelle [mailto:mpopovits@h...]
Sent: Thursday, May 24, 2001 6:39 PM
To: Pro_JavaServer_Pages
Subject: [pro_jsp] Chptr 6 - Synchonization problems?
In the example framework in Chptr 6 of the 2nd edition.
The EventHandlerBase requires you to subclass and implement getURL() which
defines an url that the page will be forwarded to after the process()
method completes. In a situation where I might forward to a different
page depending on some outcome of the process() (validation, etc.).
The only that I can see to do this is to store an instance variable and
have that be used in the getURL() method to determine (ie. in an if stmt)
where to forward to next. The problem I have with this is that the
EventHandler instances are being reused and if multiple users are using
this same instance wouldn't that not cause synchronization problems?
One option I thought of was placing a synchronization block around the
calls to both process() and forward() in the controller servlet, but I'm
not sure if that is the best way (performance may take a hit).
Any suggestions would be greatly appreciated.
Thanks,
Michelle
-
|
|
 |