嵌入Jetty 9并自定义套接字地址,端口和ThreadPool? [英] Embedding Jetty 9 and customizing Socket Address, Port and ThreadPool?

查看:132
本文介绍了嵌入Jetty 9并自定义套接字地址,端口和ThreadPool?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前在应用程序中使用Jetty 8.1.14作为嵌入式Web服务器.现在,我正在尝试升级到9.2.10版.

I have previously used Jetty 8.1.14 as embedded web server in my application. Now I am trying to upgrade to version 9.2.10.

使用Jetty 8,可以使用"SelectChannelConnector"或"SslSelectChannelConnector"中的设置器以及ThreadPool作为"Server"类中的构造函数参数来指定主机地址和端口.

With Jetty 8, it was possible to specify the Host Address and Port using the setters in the "SelectChannelConnector" or "SslSelectChannelConnector", and also the ThreadPool as a constructor argument in the "Server" class.

现在,似乎只能在服务器"类中指定一个或另一个.只有地址和/或端口或要使用的ThreadPool的构造函数变体.我找不到所有这三个参数的任何变体.

Now, it seems one can only specify one or the other in the "Server" class. There are only constructor variants for the address and/or port, or the ThreadPool to use. I can't find any variant with all three arguments.

如何使用Jetty 9指定所有这些参数? 我已经尝试过:

How can I specify all those parameters with Jetty 9? I have tried:

String bindAddress = "myValue";
int port = 12345;
Server s = new Server(new InetSocketAddress(bindAdress, port));

ThreadPool t = MyHighlyCustomizedThreadPool();
Server s = new Server(t);

推荐答案

使用

Use the ServerConnector for setting listen ports, setting listen host addresses, setting idle timeouts, and setting default protocols. Once started, the same connector can be used to determine actual listening port (if using dynamically assigned ports), actual listen hosts (if using dynamic host addresses), etc ...

使用 HttpConfiguration 用于设置缓冲区,安全标识(用于安全重定向),调整标题,技术支持,服务器版本公告等.

Use the HttpConfiguration for setting buffers, secure identification (used for secure redirects), tweaking headers, powered by, server version announcement, etc..

使用 ConnectionFactory 用于控制协议选择的进度如何与最近接受的传入连接一起工作的实现. (是的,这在当今的Web基础架构中很重要)

Use ConnectionFactory implementations to control how the progression of protocol selection should work with a recently accepted incoming connection. (Yes, this is a thing that is important in today's Web infrastructure)

有关HTTP/1.1和SSL + HTTP/1.1(又称HTTPS)的基本示例,请参见

For a basic example of HTTP/1.1 and SSL+HTTP/1.1 (aka HTTPS) see the ManyConnectors.java embedded example

有关SPDY中ConnectionFactory行为的示例,请参见

For an example of ConnectionFactory behavior with SPDY, see the SpdyConnector.java example (note: SPDY has been deprecated in favor of HTTP/2 in Jetty 9.3.x)

有关使用TLS + ALPN + HTTP/2的ConnectionFactory行为的示例,请参见

For an example of ConnectionFactory behavior with TLS + ALPN + HTTP/2, see the Http2Server.java example (note: you'll need Jetty 9.3.x for this)

这篇关于嵌入Jetty 9并自定义套接字地址,端口和ThreadPool?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆