- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我已经查看了关于 Jetty 9 架构的文档 (http://www.eclipse.org/jetty/documentation/current/architecture.html),但我仍然对处理程序和连接器之间的关系感到困惑。
您能否将处理程序链接到特定的连接器(如果可以,如何?连接器似乎没有 setHandler 方法)?
还是所有内容都交给主处理程序,然后您从那里分发内容? (即你找出它来自哪个连接器,然后你将它转发给不同的处理程序或自己处理)
非常感谢!
最佳答案
连接器
是监听传入连接的组件。
处理程序
是用于处理所有 请求的低级 jetty 机制。
Jetty 将所有有效请求(有一类请求只是错误的 HTTP 使用,可能导致类似 400 Bad Request
的请求)到在 Server.getHandler 注册的任何内容()
有许多类型的函数特定处理程序,选择最适合您需求的一种并从中扩展,或者围绕更通用的方法包装您的处理程序。
典型的服务器被设置为具有 HandlerList 或 HandlerCollection 以指示可能行为的列表。
每个处理程序都被命中(按顺序),如果该处理程序决定它想做某事它可以。
如果处理程序实际产生了一些东西,则调用 baseRequest.setHandled(true);
用于告诉 Jetty 在当前处理程序之后不再处理任何处理程序。
至于如何将某些处理程序限制到某些连接器,这是通过虚拟主机机制完成的。
VirtualHosts 是融入 ContextHandler
特定处理程序的概念,因此您需要将自定义处理程序包装在 ContextHandler
中以获得 VirtualHosts 的好处。
要使用它,您可以使用 Connector.setName(String)
命名您的连接器,然后在 的 VirtualHosts 定义上使用
到特定的只有那个命名的连接器可以用于服务那个特定的 @{name}
语法>ContextHandlerContextHandler
。
例子:
ServerConnector httpConnector = new ServerConnector(server);
httpConnector.setName("unsecured"); // named connector
httpConnector.setPort(80);
ContextHandler helloHandler = new ContextHandler();
helloHandler.setContextPath("/hello");
helloHandler.setHandler(new HelloHandler("Hello World"));
helloHandler.setVirtualHosts(new String[]{"@unsecured"});
关于java - jetty 9 : Setting up handlers and connectors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26148418/
在没有指定上下文和上下文处理程序的情况下启动 jetty 实例是否正确,然后在服务器启动后继续向其添加上下文。尽管我能够使用可变 HandlerCollection 执行此操作并且日志显示服务器和上下
在没有指定上下文和上下文处理程序的情况下启动 jetty 实例是否正确,然后在服务器启动后继续向其添加上下文。尽管我能够使用可变 HandlerCollection 执行此操作并且日志显示服务器和上下
我正在尝试让 Jetty 在我的 Ubuntu 上自动启动。 我已经完成了这些命令: cp /opt/jetty/bin/jetty.sh /etc/init.d update-rc.d jett
我是 Jetty 和客户端/服务器架构的新手。 我设法在 Eclipse 中编写了一个 jetty 服务器,它可以工作。 但是我怎样才能停止 jetty 服务器呢?我听说过 stop.jar 和 st
我已经使用Jetty / tomcat应用服务器使用Spring Web应用程序工作了大约两年了,但是让我感到困惑的是如何在这些服务器中处理多个请求。我知道 Spring 有助于单例,但我的理解仅限于
我正在尝试使用 jetty 来使用 maven 托管一个简单的 helloworld servlet。我很困惑。 我关注了这些 instructions ,但是当我发出 mvn jetty:run ,
我正在使用 Jetty 9,我有 jetty.base 和 jetty.home,我想知道我什么时候启动 jetty,它以什么样的顺序调用 jetty.base 和 jetty.home,我的意思是一
我有一个 Ubuntu 服务器 10.10 64 位 在 上运行 Web 应用程序 jetty 6.1.24-6 在 Sun 的 JVM ,两者都是从标准 Ubuntu 存储库安装的。 我正在尝试查找
我在集成测试中使用 ShrinkWrap 启动 Jetty 服务器。 问题: 当我启动我的测试 jetty 服务器而不是制作我的 Controller 模型时 - 模型不起作用! 我认为原因是不同的类
使用Gradle帮助运行Jetty 9 我已经看到了在how-to-run-jetty-7-with-specified-war-with-groovy-gradle和setting_up_embed
我正在将一个项目打包到 docker jetty 镜像中,并且我正在尝试访问日志,但没有访问日志。 文件 FROM jetty:9.2.10 MAINTAINER Me "me@me.com" ADD
有没有办法解决jetty引起的文件锁定问题?完全来自 gradle ? 一些澄清: 使用 Gradle Jetty plugin 时通过运行 gradle jettyRun, jetty 导致静态资源
我最近才开始使用 Java(我最近的大部分经验都在 .NET 中)。作为这项工作的一部分,我一直在对 Jetty 和 Tomcat 进行一些比较。 我认为在我们的环境中 Tomcat 的一个功能是内置
我已将 Jetty 嵌入到 Java 应用程序中,并在 Jetty 服务器对象的实例上调用 start() 方法(在设置描述静态和动态 Web 内容位置的处理程序列表之后)。 start() 调用会阻
我正在使用 Jetty 部署生产网站。假设我的网站是 foo.com 当我将浏览器指向一个不存在的上下文(比如 foo.com/notavailable)时,Jetty 会显示一个错误页面,其中包含部
我想使用 Jetty 的嵌入式版本创建一个应用程序。不幸的是,我找不到有关我需要这样做的 jar 文件的任何信息。 Maven 存储库中有几个( http://repo2.maven.org/mave
This answer explains how the server version header can be completely removed通过使用 HttpConfiguration.s
有人可以告诉我DispatcherType在做什么吗? 似乎是重要的配置。 指向ServletContextHandler#addFilter之类的东西对类的使用也没有帮助,对我来说,“ aa”是明智
我正在尝试使用jetty gradle插件运行Jetty服务器进行功能测试。但是,我得到了java.lang.IllegalArgumentException: Object is not of ty
我需要在gradle构建中创建多种不同的模式来运行 jetty 。 它们的系统属性和类路径不同。 如何使用Gradle Jetty插件进行操作? 最佳答案 您可以创建JettyRun类型的多个任务。要
我是一名优秀的程序员,十分优秀!