Re: [Webwork-user] Session interaction
Brought to you by:
baldree,
rickardoberg
From: Maurice C . P. <Ma...@Vi...> - 2000-11-29 22:21:47
|
* Rickard Oberg (ri...@te...) wrote: > Hey > > Re: servlet agnostic session interaction. I think I have an interesting > solution to this. > > Let's introduce an interface SessionAware, which contains the method > public void setSession(java.util.Map session); > > When the action is created it is tested for SessionAware, and if the action > implements it, it is called. However, since we want to keep the action > servlet agnostic, it will get a Map and not the real Session. This Map will > be a proxy object that simply converts the Map calls to Session calls. Very elegant. > > This way it should still be possible to run all actions without a servlet > environment, for example in automatic testing (e.g. regression tests), and > it should also be possible to reuse them in a Swing GUI, in which case the > session is simply a HashMap or similar. True. The concept of a session is not particular to HTTP programming. > > What do you think? Some of the methods in Session are not available in Map, > but I figured it is "good enough" and one can always get to those extra > methods by using ServletAware. More than "good enough". If you need the other methods you are probably worried about more than just maintaining state and should be using ServletAware. > > Is this nirvana yet? Yes! Later, Maurice |