You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sumit Agarwal <20...@gmail.com> on 2009/03/07 15:33:02 UTC

Struts 2 instance creation in memorey

Well Nice to meet all of forum member.

Well i have some doubt regarding Struts2.
1.I have read action instance is created for each request.

Suppose we have one struts2 application.we are given 2 request for this
application from different system at a time.As per Struts2 two Action
instance will be created right?

I wanna know how many value stack instance  will get create in memory?
How many Action context instance will get create in memory?

how many interceptor instance will get create?

I am looking forward to hear from you all regarding these points.

Thanks in advance!!




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


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


Re: Struts 2 instance creation in memorey

Posted by mu...@aol.com.
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 <20...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



Re: Struts 2 instance creation in memorey

Posted by Sumit Agarwal <20...@gmail.com>.
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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts-2-blank which issue?

Posted by Dave Newton <ne...@yahoo.com>.
Michael Finney wrote:
> Yes. I'm looking for a means of notification as opposed to trying the
> command out every couple months.

The dev list is where Struts meta-discussions take place; any voting 
etc. would visible there.

Dave


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


RE: struts-2-blank which issue?

Posted by Michael Finney <fi...@ACM.org>.
Yes. I'm looking for a means of notification as opposed to trying the
command out every couple months.

-- 
Michael Finney - "Always Striving To Serve You Better Every Day"
finney@ACM.org
http://www.SmilingSoftwareSolutions.com

-----Original Message-----
Michael Finney wrote:
> For the struts-2-blank archetype
> (http://struts.apache.org/2.x/docs/struts-2-blank-archetype.html ), is the
> best (most relevant) issue to "Watch"
> https://issues.apache.org/struts/browse/WW-2911 ?

Watch for what, for when it's done? It's in the repository and is just 
waiting for me (or someone with actual time :/ to do the prep work for 
an official vote, at which point it can be released.

Dave




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


Re: struts-2-blank which issue?

Posted by Dave Newton <ne...@yahoo.com>.
Michael Finney wrote:
> For the struts-2-blank archetype
> (http://struts.apache.org/2.x/docs/struts-2-blank-archetype.html ), is the
> best (most relevant) issue to "Watch"
> https://issues.apache.org/struts/browse/WW-2911 ?

Watch for what, for when it's done? It's in the repository and is just 
waiting for me (or someone with actual time :/ to do the prep work for 
an official vote, at which point it can be released.

Dave


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


struts-2-blank which issue?

Posted by Michael Finney <fi...@ACM.org>.
Hi,

For the struts-2-blank archetype
(http://struts.apache.org/2.x/docs/struts-2-blank-archetype.html ), is the
best (most relevant) issue to "Watch"
https://issues.apache.org/struts/browse/WW-2911 ?

Thanks.

-- 
Michael Finney - "Always Striving To Serve You Better Every Day"
finney@ACM.org
http://www.SmilingSoftwareSolutions.com



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


Re: Struts 2 instance creation in memorey

Posted by Dave Newton <ne...@yahoo.com>.
Sumit Agarwal wrote:
>  in Struts2 we are having DispatcherFilter instead of Servlet.is
> there any advantage using filter instead of Servlet?

I don't know how much of an advantage there is. This topic has been 
brought up several times; searching the Struts or WebWork archives might 
provide some answers, or someone smarter than me might jump in :)

> are we having any FrontServlet in Struts2?

No, just the filter.

Dave


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


RE: Struts 2 instance creation in memorey

Posted by Martin Gainty <mg...@hotmail.com>.
filters to modify headers, block requests and or setup a filter chain as explained in the doc
servlets for 'regular request processing and response generation'

A filter is an object than perform filtering tasks
 on either the request to a resource (a servlet or static content), or on the response from 
 a resource, or both

http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/Filter.html

Anyone?
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 




> Date: Sat, 7 Mar 2009 07:54:14 -0800
> From: 2005.sumit@gmail.com
> To: user@struts.apache.org
> Subject: Re: Struts 2 instance creation in memorey
> 
> 
> Thanks Mr Dave for your good explanation.I agreed by your explanation.
> 
> 
> Well i wanna ask you one more question.
> 
> In Struts1 we were having one Front servlet name as ActionServlet but i have
> noticed in Struts2 we are having DispatcherFilter instead of Servlet.is
> there any advantage using filter instead of Servlet?
> are we having any FrontServlet in Struts2?
> 
> Looking forward to hear from you.
> -- 
> View this message in context: http://www.nabble.com/Struts-2-instance-creation-in-memorey-tp22388082p22388902.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Express your personality in color! Preview and select themes for HotmailĀ®. 
http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme

Re: Struts 2 instance creation in memorey

Posted by Sumit Agarwal <20...@gmail.com>.
Thanks Mr Dave for your good explanation.I agreed by your explanation.


Well i wanna ask you one more question.

In Struts1 we were having one Front servlet name as ActionServlet but i have
noticed in Struts2 we are having DispatcherFilter instead of Servlet.is
there any advantage using filter instead of Servlet?
are we having any FrontServlet in Struts2?

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


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


Re: Struts 2 instance creation in memorey

Posted by Dave Newton <ne...@yahoo.com>.
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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org