【问题标题】:migrate to Jersey 2.x with fastinfoset使用 fastinfoset 迁移到 Jersey 2.x
【发布时间】:2016-02-06 23:31:28
【问题描述】:

我正在尝试将 Jersey 1.0 客户端应用程序迁移到 Jersey 2.0。到目前为止,除了 content-type 之外,一切正常:/application/fastinfoset

我使用 Jeysey 2.21.1 BOM,所以 jersey fastinfoset 包含在依赖项中。

我的问题是我没有找到如何注册 FastInfoSet。

我得到 MessageReaderBody 异常。

【问题讨论】:

  • 没试过,但看了this testthis issue,我会说不支持
  • 天哪,这很糟糕。有什么方法可以做到这一点,只需用新方法替换我的模式吗?并感谢您的回答
  • 我会尝试查看 Apache CXF,看看是否不能从那里获取一些代码。
  • 这里是Jersey 1.x support。我不太确定他们为什么不只是将其移植到 2.x,但我会尝试使用该实现。
  • 我为我在 JIRA for Jersey 上创建的问题创建了一个演示。该代码适用于 application/fastinfoset java.net/jira/browse/JERSEY-3053

标签: jersey-2.0 jersey-client fastinfoset


【解决方案1】:

您需要注册符合 Jersey 2 标准的 FI 提供商。类似的东西

private Client client() {
    ClientConfig config = new ClientConfig();
    config.register(FastInfosetJAXBElementProvider.class);
    config.register(FastInfosetRootElementProvider.class);
    config.property(ClientProperties.CONNECT_TIMEOUT, 5000);
    config.property(ClientProperties.READ_TIMEOUT, 15000);
    return JerseyClientBuilder.createClient(config);
}

Provider 类来自这个 repo:

https://github.com/jecklgamis/jersey-fastinfoset-provider

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    我为我在 JIRA for Jersey 上创建的问题创建了一个演示。该代码适用于 application/fastinfoset https://java.net/jira/browse/JERSEY-3053

    我为 Entity 和 InputStream 工作。我还没有介绍 MessageBodyCover。

    【讨论】:

      猜你喜欢
      • 2021-03-03
      • 1970-01-01
      • 2022-01-06
      • 2017-02-25
      • 2016-07-04
      • 2018-08-10
      • 2017-03-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多