You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mufaddal Khumri <mk...@allegrocentral.com> on 2008/01/16 04:57:40 UTC
Question on Application, Session, Request Awareness best practices ...
Hello,
Since struts2 actions are not shared amongst requests and if these
actions are Aware of one of the scopes they essentially have a copy
of that scope's parameters in a map. Lets say the application has
about 15 attributes and the session has about 7 attributes.
Que1. When you add a new application attribute, does it automatically
get added to all the present maps of that particular scope in all the
instances of a particular action that are ApplicationAware?
Que2. What are the performance implications of having such a map on
each application instance that requires access to a particular
application scoped attribute and not all?
Que3. If an action needs just one application attribute, is it better
to have an interceptor extract that from the application scope and
set it on the action?
Que4. Is it better to implement the "Awareness" of one or more of the
scope in an interceptor ? (Since interceptor instances are shared
across requests) If yes, would this map of attributes from the
particular scope get updated when a new attribute is added to that
particular scope?
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Question on Application, Session, Request Awareness best practices ...
Posted by Dave Newton <ne...@yahoo.com>.
Hmm, did you ask this question last week? Or did someone else ask almost the
exact same thing?
--- Mufaddal Khumri <mk...@allegrocentral.com> wrote:
> Since struts2 actions are not shared amongst requests and if these
> actions are Aware of one of the scopes they essentially have a copy
> of that scope's parameters in a map.
No, they have a *reference* to the parameters, not a copy.
> Que1. When you add a new application attribute, does it automatically
> get added to all the present maps of that particular scope in all the
> instances of a particular action that are ApplicationAware?
Application scope is application scope: if you add something to the
application scope then anything else that has a reference to the application
scope has access to what you added. Good luck synchronizing that.
> Que2. What are the performance implications of having such a map on
> each application instance that requires access to a particular
> application scoped attribute and not all?
Essentially none. All the interceptor does is check if an action implements
an *Aware interface and, if it does, sets the appropriate map by calling the
matching setter method.
> Que3. If an action needs just one application attribute, is it better
> to have an interceptor extract that from the application scope and
> set it on the action?
No. That would take longer, be more convoluted, and require more
configuration.
> Que4. Is it better to implement the "Awareness" of one or more of the
> scope in an interceptor ? (Since interceptor instances are shared
> across requests) If yes, would this map of attributes from the
> particular scope get updated when a new attribute is added to that
> particular scope?
I'm not even sure what you mean by that; what good would having the values in
the interceptor do for your action?
d.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org