use of org.eclipse.jetty.server.Connector in project otter by alibaba.
the class JettyEmbedIntegration method main.
public static void main(String[] args) throws Exception {
Resource jetty_xml = Resource.newSystemResource("jetty/jetty.xml");
XmlConfiguration configuration = new XmlConfiguration(jetty_xml.getInputStream());
Server server = (Server) configuration.configure();
int port = 8081;
Connector[] connectors = server.getConnectors();
for (Connector connector : connectors) {
connector.setPort(port);
}
Handler handler = server.getHandler();
if (handler != null && handler instanceof ServletContextHandler) {
ServletContextHandler servletHandler = (ServletContextHandler) handler;
servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", "/tmp/");
}
server.start();
server.join();
}
use of org.eclipse.jetty.server.Connector in project otter by alibaba.
the class JettyEmbedServer method afterPropertiesSet.
public void afterPropertiesSet() throws Exception {
Resource configXml = Resource.newSystemResource(config);
XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
server = (Server) configuration.configure();
Integer port = getPort();
if (port != null && port > 0) {
Connector[] connectors = server.getConnectors();
for (Connector connector : connectors) {
connector.setPort(port);
}
}
Handler handler = server.getHandler();
if (handler != null && handler instanceof ServletContextHandler) {
ServletContextHandler servletHandler = (ServletContextHandler) handler;
servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", htdocsDir);
}
server.start();
if (logger.isInfoEnabled()) {
logger.info("##Jetty Embed Server is startup!");
}
}
use of org.eclipse.jetty.server.Connector in project rest.li by linkedin.
the class HttpsJettyServer method getConnectors.
@Override
protected Connector[] getConnectors(Server server) {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(_keyStore);
sslContextFactory.setKeyStorePassword(_keyStorePassword);
sslContextFactory.setTrustStorePath(_keyStore);
sslContextFactory.setTrustStorePassword(_keyStorePassword);
HttpConfiguration configuration = new HttpConfiguration();
configuration.addCustomizer(new SecureRequestCustomizer());
ServerConnector sslConnector = new ServerConnector(server, sslContextFactory, new HttpConnectionFactory(configuration, HttpCompliance.RFC2616));
sslConnector.setPort(_sslPort);
Connector[] httpConnectors = super.getConnectors(server);
Connector[] connectors = new Connector[httpConnectors.length + 1];
int i = 0;
for (Connector c : httpConnectors) {
connectors[i++] = c;
}
connectors[i++] = sslConnector;
return connectors;
}
use of org.eclipse.jetty.server.Connector in project rest.li by linkedin.
the class H2cJettyServer method getConnectors.
@Override
protected Connector[] getConnectors(Server server) {
HttpConfiguration configuration = new HttpConfiguration();
ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(configuration, HttpCompliance.RFC2616), new HTTP2CServerConnectionFactory(configuration));
connector.setPort(_port);
return new Connector[] { connector };
}
use of org.eclipse.jetty.server.Connector in project h2o-3 by h2oai.
the class JettyHTTPD method startHttp.
protected void startHttp() throws Exception {
_server = new Server();
// QueuedThreadPool p = new QueuedThreadPool();
// p.setName("jetty-h2o");
// p.setMinThreads(3);
// p.setMaxThreads(50);
// p.setMaxIdleTimeMs(3000);
// _server.setThreadPool(p);
Connector connector = new SocketConnector();
connector.setHost(_ip);
connector.setPort(_port);
createServer(connector);
}
Aggregations