如何在Filter和FORWARD调度中使用码头连续性? [英] How to use jetty continuations with a Filter and FORWARD dispatching?

查看:107
本文介绍了如何在Filter和FORWARD调度中使用码头连续性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Servlet过滤器,它是我的Web堆栈的基础.在我的web.xml中 指定我希望过滤器还充当FORWARD调度程序.

I have a servlet Filter that acts as the basis of my web stack. In my web.xml I have specified that I want the filter to also act as a FORWARD dispatcher.

  <filter-mapping>
    <filter-name>MyFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>  
  </filter-mapping>

这是我框架中的另一个功能所必需的.

This is required for another feature in my framework.

现在,我正在尝试添加对异步延续的支持.我遇到的问题是 当继续恢复(或继续终止)时,码头从来不会向我的过滤器发送恢复"请求.如果我编写了一个servlet,那么它将得到恢复"的请求. 而且,如果我从web.xml文件中删除了<dispatcher>FORWARD</dispatcher>,则过滤器确实会收到恢复"请求.无论如何,即使启用了FORWARD分派,我也可以将恢复的"请求分派到我的过滤器吗?

Now I am trying to add support for asynchronous continuations. The problem I've come across is that when the continuation is resumed (or when the continuation expires) jetty is never dispatching the "resumed" request to my filter. If I write a servlet, then it will get the "resumed" request. And if I remove the <dispatcher>FORWARD</dispatcher> from my web.xml file then the filter does get the "resumed" request. Is there anyway that I can have the "resumed" request dispatched to my filter even with FORWARD dispatching enabled?

多玩了一会儿之后,只要我有任何<dispatcher>条目,就会出现问题.即使只有<dispatcher>REQUEST</dispatcher>条目.为了使其正常运行,根本不能有任何dispatcher条目.

After playing around a bit more, the problem arises whenever I have any <dispatcher> entries. Even if there is only a <dispatcher>REQUEST</dispatcher> entry. In order for it to work, there must be no dispatcher entries at all.

推荐答案

在仔细阅读了Jetty源代码之后,我找到了答案.原来Jetty支持另一个 调度程序类型称为ASYNC.因此,如果我将任何<dispatcher>行添加到web.xml的<filter-mapping>部分,则必须包含ASYNC的条目,因为在分派继续"延续时,即使用的分派器类型.

After digging through the Jetty source code I found the answer. Turns out that Jetty supports another dispatcher type called ASYNC. So if I add any <dispatcher> lines to the <filter-mapping> section of the web.xml, I have to include an entry for ASYNC because when a "resumed" continuation is dispatched, that is the dispatcher type that is used.

<filter-mapping>
  <filter-name>MyFilter</filter-name>
  <url-pattern>/*</url-pattern>
  <dispatcher>REQUEST</dispatcher>
  <dispatcher>FORWARD</dispatcher>
  <dispatcher>ASYNC</dispatcher>
</filter-mapping>

这篇关于如何在Filter和FORWARD调度中使用码头连续性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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