|
|
|
@ -1,15 +1,20 @@
|
|
|
|
|
package cn.hippo4j.springboot.starter.adapter.web;
|
|
|
|
|
|
|
|
|
|
import cn.hippo4j.adapter.web.JettyWebThreadPoolHandler;
|
|
|
|
|
import cn.hippo4j.adapter.web.TomcatWebThreadPoolHandler;
|
|
|
|
|
import cn.hippo4j.adapter.web.WebThreadPoolRunStateHandler;
|
|
|
|
|
import org.apache.catalina.startup.Tomcat;
|
|
|
|
|
import org.apache.coyote.UpgradeProtocol;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
|
|
|
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.eclipse.jetty.server.Server;
|
|
|
|
|
import org.eclipse.jetty.util.Loader;
|
|
|
|
|
import org.eclipse.jetty.webapp.WebAppContext;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.Servlet;
|
|
|
|
|
|
|
|
|
@ -34,4 +39,20 @@ public class WebThreadPoolHandlerConfiguration {
|
|
|
|
|
return new TomcatWebThreadPoolHandler(webThreadPoolRunStateHandler);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
@ConditionalOnClass({ Servlet.class, Server.class, Loader.class, WebAppContext.class })
|
|
|
|
|
@ConditionalOnBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
|
|
|
|
|
static class EmbeddedJetty {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Refer to the Server loading source code .
|
|
|
|
|
* This load is performed if the {@link Server} class exists and
|
|
|
|
|
* the Web embedded server loads the {@link ServletWebServerFactory} top-level interface type at the same time
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
public JettyWebThreadPoolHandler jettyWebThreadPoolHandler() {
|
|
|
|
|
return new JettyWebThreadPoolHandler();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|