}
protected void setupThreadPool() {
AbstractConnector aconn = (AbstractConnector) connector;
if (isSetThreadingParameters()) {
ThreadPool pool = aconn.getThreadPool();
if (pool == null) {
pool = aconn.getServer().getThreadPool();
}
if (pool == null) {
pool = new QueuedThreadPool();
aconn.getServer().setThreadPool(pool);
aconn.setThreadPool(pool);
}
//threads for the acceptors and selectors are taken from
//the pool so we need to have room for those
int acc = aconn.getAcceptors() * 2;
if (getThreadingParameters().isSetMaxThreads()
&& getThreadingParameters().getMaxThreads() <= acc) {
throw new Fault(new Message("NOT_ENOUGH_THREADS", LOG,
port,
acc + 1,
getThreadingParameters().getMaxThreads(),
acc));
}
if (pool instanceof QueuedThreadPool) {
QueuedThreadPool pl = (QueuedThreadPool)pool;
if (getThreadingParameters().isSetMinThreads()) {
pl.setMinThreads(getThreadingParameters().getMinThreads());
}
if (getThreadingParameters().isSetMaxThreads()) {
pl.setMaxThreads(getThreadingParameters().getMaxThreads());
}
} else {
try {
if (getThreadingParameters().isSetMinThreads()) {
pool.getClass().getMethod("setMinThreads", Integer.TYPE)
.invoke(pool, getThreadingParameters().getMinThreads());
}
if (getThreadingParameters().isSetMaxThreads()) {
pool.getClass().getMethod("setMaxThreads", Integer.TYPE)
.invoke(pool, getThreadingParameters().getMaxThreads());
}
} catch (Throwable t) {
//ignore - this won't happen for Jetty 7.1 - 7.2 and 7.3 and newer
//will be instanceof QueuedThreadPool above