You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Senthivel U S <se...@uaeexchange.com> on 2004/04/06 07:57:53 UTC

Action Class - No of instances

Greetings,

Programming Jakarta Struts by Chuck Cavaness book says always there will be
only one instance of Action Class but we have checked with the application
and found that there are more than one instance of same action class even
though the same instance is serving simultaneous requests. Please any one
can clarify us.

Rgds,

IT Support


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


Re: Action Class - No of instances

Posted by Craig McClanahan <cr...@apache.org>.
Senthivel U S wrote:

>Greetings,
>
>Thanks Mr Craig and Mr Niall.
>
>Yes we are having sub application modules and we are having one common
>action Class for some action mappings (design based on struts-scaffold -
>Refer: Struts In Action).I have to check it whether it is for module or for
>application. Actually What we thought is minimum number of same action class
>instance will serve for maximum number of requests. That is for example, if
>ten action elements are mapped to the same action class, in less user
>traffic, five action instance is enough to serve, need not create ten
>instance of the same action class. (but I think the struts specification is
>slightly different)
>
>  
>

Niall was correct on this, by the way, but so was I (sort of :-).  If 
you have an <action> element specifying the same Action class in two 
modules, you'll get two instances.

As others have pointed out, your Action classes need to be able to 
handle multiple simultaneous requests -- there is no locking going on, 
so there is no performance penalty for sharing.  Most importantly, that 
means you should avoid using instance variables in your Action classes 
to store things that are specific to an individual request -- use local 
variables inside your methods and most of the potential problems of 
simultaneous requests go away, since the JVM will create those variables 
on the stack associated with each request thread.

>Rgds,
>
>Sen
>
>  
>
Craig


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


RE: Action Class - No of instances

Posted by Andrew Hill <an...@gridnode.com>.
No, remember that multiple threads for different requests are going to be
simultaneously excuting in the action. (So be sure to keep your code
thread-safe (stay away from using class member variables etc...) just like
you would with a servlet.))

-----Original Message-----
From: Senthivel U S [mailto:senthivel.usilappan@uaeexchange.com]
Sent: Wednesday, 7 April 2004 15:06
To: 'Struts Users Mailing List'
Subject: Action Class - No of instances


Greetings,

I have one more doubt, if one instance per module/application, Is not a
performance bottleneck.

Rgds,

Sen


Greetings,

Thanks Mr Craig and Mr Niall.

Yes we are having sub application modules and we are having one common
action Class for some action mappings (design based on struts-scaffold -
Refer: Struts In Action).I have to check it whether it is for module or for
application. Actually What we thought is minimum number of same action class
instance will serve for maximum number of requests. That is for example, if
ten action elements are mapped to the same action class, in less user
traffic, five action instance is enough to serve, need not create ten
instance of the same action class. (but I think the struts specification is
slightly different)

Rgds,

Sen

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Tuesday, April 06, 2004 10:32 PM
To: Struts Users Mailing List
Subject: Re: Action Class - No of instances

I think it is per Struts module rather than webapp (in Struts 1.1)  -
actions are cached in the RequestProcessor and each Struts module has its
own RequestProcessor.

Do you have the same Action class in use in different Struts modules?

Niall

----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, April 06, 2004 6:56 PM
Subject: Re: Action Class - No of instances


> Senthivel U S wrote:
>
> >Greetings,
> >
> >Programming Jakarta Struts by Chuck Cavaness book says always there will
be
> >only one instance of Action Class but we have checked with the
application
> >and found that there are more than one instance of same action class even
> >though the same instance is serving simultaneous requests. Please any one
> >can clarify us.
> >
> >
> The standard Struts 1.1 request processor creates one Action instance
> per <action> element in your configuration file.  Therefore, the only
> way you'd get more than one such instance (in the same webapp) is if
> you've got more than one <action> element mapped to the same
> implementation class.
>
> >Rgds,
> >
> >IT Support
> >
> >
> Craig
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



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


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


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



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


Action Class - No of instances

Posted by Senthivel U S <se...@uaeexchange.com>.
Greetings,

I have one more doubt, if one instance per module/application, Is not a
performance bottleneck.

Rgds,

Sen


Greetings,

Thanks Mr Craig and Mr Niall.

Yes we are having sub application modules and we are having one common
action Class for some action mappings (design based on struts-scaffold -
Refer: Struts In Action).I have to check it whether it is for module or for
application. Actually What we thought is minimum number of same action class
instance will serve for maximum number of requests. That is for example, if
ten action elements are mapped to the same action class, in less user
traffic, five action instance is enough to serve, need not create ten
instance of the same action class. (but I think the struts specification is
slightly different)

Rgds,

Sen

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk] 
Sent: Tuesday, April 06, 2004 10:32 PM
To: Struts Users Mailing List
Subject: Re: Action Class - No of instances

I think it is per Struts module rather than webapp (in Struts 1.1)  -
actions are cached in the RequestProcessor and each Struts module has its
own RequestProcessor.

Do you have the same Action class in use in different Struts modules?

Niall

----- Original Message ----- 
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, April 06, 2004 6:56 PM
Subject: Re: Action Class - No of instances


> Senthivel U S wrote:
>
> >Greetings,
> >
> >Programming Jakarta Struts by Chuck Cavaness book says always there will
be
> >only one instance of Action Class but we have checked with the
application
> >and found that there are more than one instance of same action class even
> >though the same instance is serving simultaneous requests. Please any one
> >can clarify us.
> >
> >
> The standard Struts 1.1 request processor creates one Action instance
> per <action> element in your configuration file.  Therefore, the only
> way you'd get more than one such instance (in the same webapp) is if
> you've got more than one <action> element mapped to the same
> implementation class.
>
> >Rgds,
> >
> >IT Support
> >
> >
> Craig
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



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


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


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


Action Class - No of instances

Posted by Senthivel U S <se...@uaeexchange.com>.
Greetings,

Thanks Mr Craig and Mr Niall.

Yes we are having sub application modules and we are having one common
action Class for some action mappings (design based on struts-scaffold -
Refer: Struts In Action).I have to check it whether it is for module or for
application. Actually What we thought is minimum number of same action class
instance will serve for maximum number of requests. That is for example, if
ten action elements are mapped to the same action class, in less user
traffic, five action instance is enough to serve, need not create ten
instance of the same action class. (but I think the struts specification is
slightly different)

Rgds,

Sen

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk] 
Sent: Tuesday, April 06, 2004 10:32 PM
To: Struts Users Mailing List
Subject: Re: Action Class - No of instances

I think it is per Struts module rather than webapp (in Struts 1.1)  -
actions are cached in the RequestProcessor and each Struts module has its
own RequestProcessor.

Do you have the same Action class in use in different Struts modules?

Niall

----- Original Message ----- 
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, April 06, 2004 6:56 PM
Subject: Re: Action Class - No of instances


> Senthivel U S wrote:
>
> >Greetings,
> >
> >Programming Jakarta Struts by Chuck Cavaness book says always there will
be
> >only one instance of Action Class but we have checked with the
application
> >and found that there are more than one instance of same action class even
> >though the same instance is serving simultaneous requests. Please any one
> >can clarify us.
> >
> >
> The standard Struts 1.1 request processor creates one Action instance
> per <action> element in your configuration file.  Therefore, the only
> way you'd get more than one such instance (in the same webapp) is if
> you've got more than one <action> element mapped to the same
> implementation class.
>
> >Rgds,
> >
> >IT Support
> >
> >
> Craig
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



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


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


Re: Action Class - No of instances

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
I think it is per Struts module rather than webapp (in Struts 1.1)  -
actions are cached in the RequestProcessor and each Struts module has its
own RequestProcessor.

Do you have the same Action class in use in different Struts modules?

Niall

----- Original Message ----- 
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, April 06, 2004 6:56 PM
Subject: Re: Action Class - No of instances


> Senthivel U S wrote:
>
> >Greetings,
> >
> >Programming Jakarta Struts by Chuck Cavaness book says always there will
be
> >only one instance of Action Class but we have checked with the
application
> >and found that there are more than one instance of same action class even
> >though the same instance is serving simultaneous requests. Please any one
> >can clarify us.
> >
> >
> The standard Struts 1.1 request processor creates one Action instance
> per <action> element in your configuration file.  Therefore, the only
> way you'd get more than one such instance (in the same webapp) is if
> you've got more than one <action> element mapped to the same
> implementation class.
>
> >Rgds,
> >
> >IT Support
> >
> >
> Craig
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



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


Re: Action Class - No of instances

Posted by "Craig R. McClanahan" <cr...@apache.org>.
Senthivel U S wrote:

>Greetings,
>
>Programming Jakarta Struts by Chuck Cavaness book says always there will be
>only one instance of Action Class but we have checked with the application
>and found that there are more than one instance of same action class even
>though the same instance is serving simultaneous requests. Please any one
>can clarify us.
>  
>
The standard Struts 1.1 request processor creates one Action instance 
per <action> element in your configuration file.  Therefore, the only 
way you'd get more than one such instance (in the same webapp) is if 
you've got more than one <action> element mapped to the same 
implementation class.

>Rgds,
>
>IT Support
>  
>
Craig



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