Re: Struts 2 instance creation in memorey
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
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
RE: Struts 2 instance creation in memorey
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.su...@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-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@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
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-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
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-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 instance creation in memorey
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