Hi Remy,
I want to go the other way and decrease the number of servlets created
due to the heavy amount of objects hanging off each of these servlets.
What I have done is modify the addInitParameter method to look for an
init parameter "stm-max-instances" thus allowing the parameter to be
placed in the web.xml as a servlet init parameter.
Do you see any problems with using the approach (code below).
------------------------
package test.tomcat;
import org.apache.catalina.core.StandardWrapper;
public class STMStandardWrapper extends StandardWrapper {
private static final String MAX_STM_INSTANCES_INIT_PARAMETER =
"stm-max-instances";
public STMStandardWrapper() {
super();
}
public void addInitParameter(String name, String value) {
super.addInitParameter(name, value);
if (MAX_STM_INSTANCES_INIT_PARAMETER.equals(name)) {
try {
int max = Integer.parseInt(value);
System.out.println("Override default max instances for servlet"
+ getServletName()
+ "("
+ getServletClass()
+ ") to "
+ value);
super.setMaxInstances(max);
} catch (NumberFormatException nfe) {
System.out.println("Servlet init parameter '"
+ MAX_STM_INSTANCES_INIT_PARAMETER
+ "' for servlet "
+ getServletName()
+ "("
+ getServletClass()
+ ") was not an integer ("
+ value
+ ")");
}
}
}
}
------------------------
Kind regards
James McIntosh
On Thu, 2007-02-22 at 03:57 +0100, Rémy Maucherat wrote:
> On 2/22/07, James McIntosh <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I am trying to find out how to limit the number of Single Threaded Model
> > servlets which get created by the StandardWrapper.
> >
> > I have looked at the API and there is a setMaxInstances(int) method but
> > I cannot find anywhere in the config xml files to change it.
> > I did find the "wrapperClass" attribute for the <Context> element which
> > allows you to override StandardWrapper with another class which I could
> > call the setMaxInstances from.
>
> Nobody asked for configuration of this before. I don't think you need
> to increase it beyond the default value in the real world: 20 threads
> for one servlet is significant.
>
> Rémy
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]