Created
May 8, 2014 13:17
-
-
Save ingramchen/98d0cc3b325999fa0a7a to your computer and use it in GitHub Desktop.
Embed Tomcat with nio connector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tomcat tomcat = .... | |
final Connector nioConnector = new Connector(Http11NioProtocol.class.getName()); | |
nioConnector.setPort(58090); | |
nioConnector.setSecure(false); | |
nioConnector.setScheme("http"); | |
nioConnector.setProtocol("HTTP/1.1"); | |
try { | |
nioConnector.setProperty("address", InetAddress.getByName("localhost").getHostAddress()); | |
} catch (Exception e) { | |
throw new RuntimeException("unexpected", e); | |
} | |
tomcat.getService().removeConnector(tomcat.getConnector()); | |
tomcat.getService().addConnector(nioConnector); | |
tomcat.setConnector(nioConnector); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment