Hi Sumit -- the two are different. Easiest to illustrate by example:

Definitions:
Interceptor stack: an ordered list of interceptors with pre/post processing 
logic. You have one.

Value stack: a stack (in data structure sense) that holds javabeans including 
your current action. You have one *per request*
When an interceptor calls a method on an action it will be the action sitting 
on the value stack of the *current request*.

So if I have 
an action called "test"?with action class TestAction and?action method 
execute()?
?configured to use TestInterceptor which calls method testMethod of the action 
before execute() runs
?and I send three requests to the "test" action I will have
one testInterceptor object but get a new?value stack with a new testAction 
object each time?(testAction1, testAction2, testAction3).

The?method call sequence till be? testInterceptor.intercept() -- 
testAction1.testMethod() -- testAction1.execute()
then testInterceptor.intercept() -- testAction2.testMethod() -- 
testAction2.execute()
then testInterceptor.intercept() -- testAction3.testMethod() -- 
testAction2.execute()

Note that testInterceptor is shared and so not thread safe but the actions are 
thread safe.
Hope that helps.
Cheers
Chris Mawata








-----Original Message-----
From: Sumit Agarwal <2005.su...@gmail.com>
To: user@struts.apache.org
Sent: Mon, 16 Mar 2009 9:26 pm
Subject: Re: Struts 2 instance creation in memorey




Well i have one doubt regarding interceptor and value stack:-

i have read interceptor can store and read the data from value stack.well if
interceptor is defined in the stack.as per below answer one stack will be
create for interceptor and  two instance(for two request) for value stack
then in this case which value stack instance will be refer by the
interceptor?
looking forward to hear from all of you guys.

Thanks in advance.



newton.dave wrote:
> 
> Sumit Agarwal wrote:
>> we are given 2 request for this application from different system
>  > at a time.As per Struts2 two Action instance will be created right?
> 
> Correct: unlike servlets or Struts 1 actions, Struts 2 actions are 
> created per-request.
> 
>> I wanna know how many value stack instance will get create in memory?
> 
> Two, one for each action, otherwise it'd defeat the purpose of having 
> separate action instances.
> 
>> How many Action context instance will get create in memory?
> 
> Action contexts are thread-local variables, and there's one per... 
> action context.
> 
>> how many interceptor instance will get create?
> 
> Depends, but in general there will be one interceptor stack for a Struts 
> 2 package, and it's created at startup, not per-request.
> 
> If an action has configured its own interceptors then there can be 
> multiple interceptor stacks, but they're still not created per-request 
> (and interceptors are not inherently thread-safe).
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Struts-2-instance-creation-in-memorey-tp22388082p22537006.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Reply via email to