Thanks Max and Craig for your responses.
I agree with the overheads of pooling a stateful "entity" probably doesn't
justify its inclusion.

I was not looking for an api which gives me a session object after taking
the request object as an input parameter which as Craig points out is too
simplistic.

However, lets go by the "Threadlocal trickery". It may be a little tricky..
but then the regular struts user doesnt have to worry about it. It can be
implemented under the hood .. unless someone tells me its again going to be
a performance overhead to do it under the hood.

Going back to the specific use case I was referring to... I do not like
passing the 'user' object around. The code is executing in the context of
the user and any function written in the action class should have access to
it. Note that I dont like passing around the request/session object either
(if it can be got through a call like "getSession()" or "getRequest()" ....
dont know if I am missing something somewhere... but should not this be
possible through ThreadLocal?

Regards,
Raghu


On 11/23/05, Craig McClanahan <[EMAIL PROTECTED]> wrote:
>
> On 11/22/05, Max Cooper <[EMAIL PROTECTED]> wrote:
> >
> > A single instance of each Action class is used to service multiple
> > simultaneous requests (just like a Servlet). If you want the session,
> > you have to pass it around (or pass the request around, from which you
> > can navigate to the session).
> >
> > Having a no-argument getSession() method on Action would require a
> > unique Action instance for each request (or Action instance pooling, or
> > thread-local trickery).
>
>
> Max is correct ... however the alternative would be to implement the
> method
> like this:
>
>    protected HttpSession(HttpServletRequest request) {
>        return request.getSession();
>    }
>
> Of course, that's so simple that there is not much value add in providing
> a
> helper method for it.  Seems simpler just to call request.getSession()
> yourself.
>
> -Max
>
>
> Craig
>
>

Reply via email to