-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement
Description
I think there may be some benefits in terms of memory usage and, perhaps, the ability to easily share access log configuration, thread pools, etc.
The configuration would look a bit like this:
@Bean
public TomcatEmbeddedServletContainerFactory tomcatFactory() {
return new TomcatEmbeddedServletContainerFactory() {
@Override
protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(
Tomcat tomcat) {
Server server = tomcat.getServer();
Service service = new StandardService();
service.setName("other-port-service");
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(8081);
service.addConnector(connector);
server.addService(service);
Engine engine = new StandardEngine();
service.setContainer(engine);
Host host = new StandardHost();
host.setName("other-port-host");
engine.addChild(host);
engine.setDefaultHost(host.getName());
Context context = new StandardContext();
context.addLifecycleListener(new FixContextListener());
context.setName("other-port-context");
context.setPath("");
host.addChild(context);
Wrapper wrapper = context.createWrapper();
wrapper.setServlet(new MyServlet());
wrapper.setName("other-port-servlet");
context.addChild(wrapper);
context.addServletMapping("/", wrapper.getName());
return super.getTomcatEmbeddedServletContainer(tomcat);
}
};
}If there proves to be some benefit to this approach, we'd probably want to figure out how to do the same with Jetty and Undertow.
Metadata
Metadata
Assignees
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement