Hi all,
I was reading the "Strutting Your Stuff" article in the latest Java
Developers Journal about, of course, Struts, and saw an idea in Struts that
I thought we should steal.... umm, borrow. Basically, the idea was that the
Actions would be saved in the session and reused on the next request.
Towards this end, I built a first pass at this. Basically, I created an
empty placeholder Interface, webwork.action.Sessionable, that serves as a
flag that an Action should be saved and reused in the Session. I also built
an ActionFactoryProxy, SessionActionFactoryProxy, which looks for the Action
in a map saved in the session map keyed on the name passed to the
getActionImpl(aName) method. If it finds it, it returns this Action. If not,
it gets the action by passing the request down the ActionFactoryProxy chain.
If the Action it gets from the next Proxy implements Sessionable, then it
saves it in the map in the session for next time.
I thought this could be very useful, especially for things like multi-page
forms, so instead of passing all of the variables every time, they're just
there, in the Action, when it's activated the next time. It would also save
your current position in the workflow (because the command property would
also be saved).
One potential gotcha would be multiple hits from the same browser at the
same time to the same Action. Not an extremely likely case, but possible,
especially if your Action takes some time to run, and your users like to hit
refresh. I suppose you could control this by making all of your setters and
doXXX methods synchronized, so setters and doXXX methods couldn't be called
at the same time, and no two doXXX methods could be called at the same time.
Anyway, let me know if there's interest, and I'll submit this change.
Later,
Jason Carreira
--
Jason Carreira
Lead Systems Architect, Notiva Corp.
phone: 585.240.2793
fax: 585.272.8118
email: jas...@no...
|