You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shahak Nagiel <sn...@yahoo.com> on 2007/04/15 15:42:33 UTC

Interceptors and thread-safety

The "Writing Interceptors" guide pretty clearly states that "Interceptors are shared between requests and must be thread-safe."   However, there are some Interceptors--such as execAndWait and roles--which accept parameters (e.g. "delay" and "allowedRoles") and which, ostensibly at least--use simple setter methods to apply these to instance variables.  So, how can these be thread-safe if new Interceptors aren't being instantiated for every request?

Thanks in advance.

Re: Interceptors and thread-safety

Posted by Laurie Harper <la...@holoweb.net>.
Dave Newton wrote:
> --- Laurie Harper <la...@holoweb.net> wrote:
>> Shahak Nagiel wrote:
>>> So, how can these [interceptors] be thread-safe if 
>>> new Interceptors aren't being instantiated for
> every
>>> request?
>> Because the parameters don't come from (or vary
>> with) the request. 
> 
> Just to add on/clarify a little bit, this also implies
> that if you configure an interceptor for a specific
> action that an instance is created for that action,
> yes?

I don't know the answer to that, but I would expect it to work that 
way... I would guess there will be one interceptor instance for each 
interceptor config.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Interceptors and thread-safety

Posted by Dave Newton <ne...@yahoo.com>.
--- Laurie Harper <la...@holoweb.net> wrote:
> Shahak Nagiel wrote:
>> So, how can these [interceptors] be thread-safe if 
>> new Interceptors aren't being instantiated for
every
>> request?
> Because the parameters don't come from (or vary
> with) the request. 

Just to add on/clarify a little bit, this also implies
that if you configure an interceptor for a specific
action that an instance is created for that action,
yes?

Dave


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Interceptors and thread-safety

Posted by Laurie Harper <la...@holoweb.net>.
Shahak Nagiel wrote:
> The "Writing Interceptors" guide pretty clearly states that "Interceptors are shared between requests and must be thread-safe."   However, there are some Interceptors--such as execAndWait and roles--which accept parameters (e.g. "delay" and "allowedRoles") and which, ostensibly at least--use simple setter methods to apply these to instance variables.  So, how can these be thread-safe if new Interceptors aren't being instantiated for every request?

Because the parameters don't come from (or vary with) the request. 
Interceptor parameters are passed in once, when the interceptor is 
instantiated. That same instance is then applied to each request for 
which it's configured.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org